#include #include using namespace atcoder; using mint=modint998244353; using namespace std; using ll=long long; using ull=unsigned long long; #define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++) #define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--) #define MOD 998244353 //#define MOD 1000000007 #define INF 1e18 #define Pair pair //#define PI numbers::pi //#define E numbers::e template bool chmax(T& a,T b){if(a bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} ll dx[4]={0,1,0,-1}; ll dy[4]={1,0,-1,0}; int main(){ ll n; cin >> n; vector a(n); rep(i,0,n) cin >> a[i]; vector> dp(n,vector(100001,0)); rep(i,a[0],100001) dp[0][i]=1; vector sum(100001,0); sum[0]=dp[0][0]; rep(i,1,100001) sum[i]=(sum[i-1]+dp[0][i])%MOD; if(n>=2){ rep(i,1,n){ rep(j,a[i],100001){ ll x=j-a[i]; dp[i][j]=sum[min(j,x+a[i-1])]; } sum[0]=dp[i][0]; rep(j,1,100001) sum[j]=(sum[j-1]+dp[i][j])%MOD; } } cout << sum[100000] << endl; }