N=int(input()) A=list(map(int,input().split())) dp=[[0]*(10**5+1) for i in range(N+1)] v=[[0]*(10**5+1) for i in range(N+1)] for i in range(A[0],10**5+1): dp[1][i]=1 for i in range(10**5+1): v[1][i]=v[1][i-1]+dp[1][i] mod=998244353 for i in range(1,N): if A[i]>=A[i-1]: for j in range(A[i],10**5+1): w=j-(A[i]-A[i-1]) if w<0: continue dp[i+1][j]=v[i][w] else: for j in range(A[i],10**5+1): dp[i+1][j]=v[i][j] for j in range(10**5+1): v[i+1][j]=v[i+1][j-1]+dp[i+1][j] v[i+1][j]%=mod print(v[N][10**5])