MOD = 998_244_353 def main(N, K, A): S = [0] * (N+1) for i in range(N): S[i + 1] = S[i] + A[i] if any(a > b for a, b in zip(A[1:], S[1:])): return 0 v = A[-1] - 1 ans = 1 for n in range(N - 2, -1, -1): s, a = S[n], A[n] if v < s + a - 1: pass else: ans = ans * (A[n] + K + 1) % MOD v = max(a - 1, v // 2) return res N, K = map(int, input().split()) A = list(map(int, input().split())) print(main(N, K, A))