#include using namespace std; using mint = atcoder::modint998244353; int main(){ int n; cin >> n; vector a(n); for(auto &&v:a) cin >> v; vector dp(n + 1); dp[0] = 1; for(int i = 0; i < n; i++){ int l = i, r = i; while(l >= 0 && a[l] >= a[i])l--; while(r < n && a[r] >= a[i])r++; for(int j = l + 1; j < r; j++)dp[j + 1] += dp[j]; } cout << dp[n].val() << endl; }