/* -*- coding: utf-8 -*- * * 2433.cc: No.2433 Min Increasing Sequence - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MOD = 998244353; const int INF = 1 << 30; /* typedef */ /* global variables */ int as[MAX_N + 1], ls[MAX_N + 1], dp[MAX_N + 1], ss[MAX_N + 1]; /* subroutines */ inline void addmod(int &a, int b) { a = (a + b) % MOD; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); as[n] = INF; ls[n] = n; dp[n] = ss[n] = 1; for (int i = n - 1; i >= 0; i--) { ls[i] = (as[i] <= as[ls[i + 1]]) ? i : ls[i + 1]; dp[i] = ss[ls[i] + 1]; ss[i] = (dp[i] + ss[i + 1]) % MOD; } printf("%d\n", dp[0]); return 0; }