#include #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; const ll mod = 998244353; #define fi first #define se second #define rep(i,n) for(ll i=0;i> N; vector A(N); rep(i,N) cin >> A[i]; vector> dp(N,vector(100500,0)); rep(j,100500) if(j>=A[0]) dp[0][j]=1; rep(i,N-1){ vector cum(100500,0); cum[0]=dp[i][0]; rep(j,100500-1) cum[j+1]=(cum[j]+dp[i][j+1])%mod; rep(j,100500){ if(j=A[i+1]) dp[i+1][j]=cum[j]; } } ll ans=0; rep(j,100000+1) ans+=dp[N-1][j]; cout << ans%mod << endl; return 0; }