## https://yukicoder.me/problems/no/2625 MOD = 998244353 MAX = 10 ** 5 def main(): N = int(input()) A = list(map(int, input().split())) dp = [0] * (MAX + 1) dp[0] = 1 cum_dp = [1] * (MAX + 1) prev = 0 for i in range(N): new_dp = [0] * (MAX + 1) for b in range(MAX - A[i] + 1): if b - max(0, prev - A[i]) >= 0: new_dp[b] = cum_dp[b - max(0, prev - A[i])] dp = new_dp cum_dp = [0] * (MAX + 1) a = 0 for b in range(MAX + 1): a += dp[b] a %= MOD cum_dp[b] = a prev = A[i] answer = 0 for b in range(MAX + 1): answer += dp[b] answer %= MOD print(answer) if __name__ == "__main__": main()