Pagini recente » Cod sursa (job #3277707) | Cod sursa (job #2619785) | Cod sursa (job #721981) | Cod sursa (job #3237262) | Cod sursa (job #1709196)
#include <cassert>
#include <fstream>
#include <cstring>
#include <queue>
#include <algorithm>
#include <bitset>
#include <ctime>
#include <set>
#include <cmath>
#include <iomanip>
#include <map>
#include <stack>
#include <vector>
#include <bitset>
#include <fstream>
using namespace std;
#define FOR(i, a, n) for (int i = a; i <= n; ++i)
#define ROF(i, n, a) for (int i = n; i >= a; i--)
#define FIT(i, v) for (auto &i : v)
#define pb push_back
#define mp make_pair
#define mt make_touple
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 19997;
ll powmod(ll a, ll b) {ll res=1; a %= mod; assert(b >= 0); for(; b; b >>= 1) {if (b & 1) res = res * a % mod; a = a * a % mod;} return res;}
const int N = 1000010;
ifstream fin("twoton.in");
ofstream fout("twoton.out");
int a[N], n, cnt[N], ok[N], wt[N];
int wtf(int i) {
if(ok[i]) {
return wt[i];
}
ok[i] = 1;
cnt[i]++;
if (cnt[i] >= mod) {
cnt[i] -= mod;
}
if (i == n - 1) {
wt[i] = a[i];
return wt[i];
}
if (a[i] < wtf(i + 1)) {
cnt[i] += cnt[i + 1];
if (cnt[i] >= mod) {
cnt[i] -= mod;
}
wt[i] = a[i];
return a[i];
} else {
cnt[i] += cnt[i + 1];
if (cnt[i] >= mod) {
cnt[i] -= mod;
}
cnt[i] += cnt[i + 1];
if (cnt[i] >= mod) {
cnt[i] -= mod;
}
wt[i] = wtf(i + 1);
return wt[i];
}
}
int main() {
fin >> n;
FOR(i,0,n-1) {
fin >> a[i];
}
wtf(0);
fout << cnt[0];
return 0;
}