/** Template by Danel Batyrbek All rights reserved 2017 (lol) */ #include #include #include #include #include #include #include #include #include using namespace std; #define fr first #define sc second #define pb push_back #define ins insert #define mkp make_pair #define all(x) x.begin(),x.end() #define speed_up ios_base::sync_with_stdio(0);cin.tie(0) #define debug cerr << "OK\n" #define fname "" typedef long long ll; typedef double ld; typedef long double lld; typedef pair pii; typedef pair pll; const int N = 1e5 + 10; const int N3 = 1e3 + 10; const int INF = 2e9 + 10; const int mod = 1e9 + 7; const ll LINF = 4e18 + 10; int n, a[N]; ll d[N]; int main(){ cin >> n; for(int i = 1; i <= n; ++ i){ cin >> a[i]; } int last = 0; int pos = 1; d[0] = 1; for(int i = 1; i <= n; ++ i){ if(a[i - 1] > a[i]){ last = pos; pos = i; } d[i] = (d[i - 1] - (last == 0 ? 0 : d[last - 1]) + mod) % mod; d[i] += d[i - 1]; d[i] %= mod; } cout << (d[n] - d[n - 1] + mod) % mod; return 0; }