import sys input = sys.stdin.readline mod=998244353 N=int(input()) A=list(map(int,input().split())) DP=[0]*100001 for i in range(A[0],100001): DP[i]=1 for j in range(1,N): a=A[j] b=A[j-1] NDP=[0]*100001 for i in range(100001): if DP[i]>=0: k=i-b # 真のスコア: i以上 # 仮のスコア: k以上 MIN=max(i,k+a) if MIN<=100000: NDP[MIN]+=DP[i] for i in range(1,100001): NDP[i]=(NDP[i]+NDP[i-1])%mod DP=NDP print(sum(DP)%mod)