MOD = 998244353 M = 10**5 n = int(input()) A = list(map(int, input().split())) dp = [0] * (M + 1) dp[0] = 1 b = 0 for a in A: for i in range(M): dp[i + 1] = (dp[i] + dp[i + 1]) % MOD add = max(0, b - a) dp = [0] * add + dp[: M + 1 - add] for i in range(M - a + 1, M + 1): dp[i] = 0 b = a print(sum(dp) % MOD)