def Map(): return list(map(int,input().split())) mod = 998244353 N = int(input()) A = Map() S = 10**5 if N == 1: print(S + 1 - A[0]) exit() dp = [[0 for j in range(S + 1)] for i in range(N)] for s in range(S + 1): if s + A[0] > S: break dp[0][s] += 1 for n in range(N-1): d = 0 if A[n] - A[n+1] > 0: d += A[n] - A[n+1] for s in range(S+1): if n > 0 and s < S: dp[n][s+1] += dp[n][s] dp[n][s+1] %= mod if s + d > S: continue ss = s + d if ss + A[n+1] > S: continue sss = S - A[n+1] + 1 dp[n+1][ss] += dp[n][s] dp[n+1][ss] %= mod if sss <= S: dp[n+1][sss] -= dp[n][s] dp[n+1][sss] %= mod ans = 0 for s in range(S): dp[N-1][s+1] += dp[N-1][s] dp[N-1][s+1] %= mod ans += dp[N-1][s] ans %= mod print(ans)