#maspyさんのコード(https://yukicoder.me/submissions/602281)をもとにつくったO(NlogK)解 def check(N,K,A): import itertools MOD = 998_244_353 def is_balanced(A, Acum): for a, b in zip(A[1:], Acum[1:]): if a > b: return False return True def main(N, K, A): S = [0] + list(itertools.accumulate(A)) if not is_balanced(A, S): return 0 res = 1 for n in range(N-2,-1,-1): tmp = A[n] - 1 + S[n] flag = False for j in range(n+1,N): if tmp > K: break if A[j]-1 >= tmp: flag = True break tmp *= 2 if flag: res *= (A[n]+1+K) res %= MOD return res return main(N,K,A) N,K = map(int,input().split()) A = list(map(int,input().split())) print(check(N,K,A))