#include //#include using namespace std; //using namespace atcoder; //using mint = modint998244353; #define rep(i,n) for(long long i=0;i vec; typedef vector> vvec; typedef vector vecll; typedef vector> vvecll; //#include //using namespace boost::multiprecision; const ll mod=998244353; //const ll mod=1e9+7; const ll INF=5e18; const int INT_INF=1e9; const double pi=3.14159265358979; //xのn乗をpで割ったあまりを求める ll modpow(ll x,ll n,ll p=mod){ if(n==0) return 1; if(n%2==1) return (x*modpow(x,n-1,p))%p; else{ ll t=modpow(x,n/2,p); assert(t>0); return (t*t)%p; } } //xの逆元(p:素数) ll inv(ll x,ll p=mod){ return modpow(x,p-2,p); } template int index(vector &a, T x){ return lower_bound(all(a),x)-a.begin(); } vector factorial_table(ll n,ll p=mod){ vector res(n+1,1); rep1(i,n){ res[i]=res[i-1]*i; res[i]%=p; } return res; } int main(){ vecll fact=factorial_table(110000LL); ll n; cin >> n; vecll a(n); rep(i,n) cin >> a[i]; ll x=0; rep(i,n-1){ x+=max(a[i]-a[i+1],0LL); } x=100000-a[n-1]-x; if(x<0){ cout << 0 << endl; }else{ //cout << x << endl; ll ans=fact[x+n]; ans*=(inv(fact[x])*inv(fact[n]))%mod; ans%=mod; cout << ans << endl; } return 0; }