import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd class Binom: def __init__(self, n, mod): self.n = n self.mod = mod self.fact = [1,1] self.factinv = [1,1] self.inv = [0,1] self._calc(n, mod) def _calc(self, n, mod): for i in range(2, n+1): self.fact.append((self.fact[-1]*i) % mod) self.inv.append((-self.inv[mod % i]*(mod//i)) % mod) self.factinv.append((self.factinv[-1]*self.inv[-1]) % mod) def comb(self,n,r): return self.fact[n]*self.factinv[r]%self.mod*self.factinv[n-r]%self.mod def perm(self,n,r): return self.fact[n]*self.factinv[n-r]%self.mod mod = 998244353 binom = Binom(10**5+10, mod) n = int(input()) a = list(map(int,input().split())) d = [0] for i in range(1, n): d.append(max(0, -(a[i] - a[i-1]))) left = [] now = 0 for i in range(n): now += d[i] tmp = a[i] + now left.append(10**5-tmp) last = left[-1] ans = 0 if last < 0: print(0) exit() for i in range(last+1): ans += binom.comb(n+i-1, i) ans %= mod # print(i, ans) print(ans)