MOD = 998244353


class DP:

    def __init__(self, X, Y, Z):
        self._X = X
        self._Y = Y
        self._Z = Z
        self._list = [0] * (X * Y * Z)
    
    def get(self, x, y, z):
        return self._list[x*(self._Y*self._Z) + y*self._Z + z]
    
    def set(self, x, y, z, v):
        self._list[x*(self._Y*self._Z) + y*self._Z + z] = v


def solve():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    # dp = [[[0 for _ in range(3)] for _ in range(S+1)] for _ in range(N+1)]
    dp = DP(N+1, S+1, 3)

    # dp[0][0][0] = 1
    dp.set(0, 0, 0, 1)

    for i in range(0, N):
        for s in range(0, S+1):
            # dp[i+1][s][0] = dp[i][s][0]
            dp.set(i+1, s, 0, dp.get(i, s, 0))
            if s - A[i] >= 0:
                # dp[i+1][s][1] = (dp[i][s][1] + dp[i][s][0] + dp[i][s-A[i]][1] + dp[i][s-A[i]][0]) % MOD
                dp.set(i+1, s, 1, (dp.get(i, s, 1) + dp.get(i, s, 0) + dp.get(i, s-A[i], 1) + dp.get(i, s-A[i], 0)) % MOD)
                # dp[i+1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0] + dp[i][s-A[i]][1] + dp[i][s-A[i]][0]) % MOD
                dp.set(i+1, s, 2, (dp.get(i, s, 2) + dp.get(i, s, 1) + dp.get(i, s, 0) + dp.get(i, s-A[i], 1) + dp.get(i, s-A[i], 0)) % MOD)
            else:
                # dp[i+1][s][1] = (dp[i][s][1] + dp[i][s][0]) % MOD
                dp.set(i+1, s, 1, (dp.get(i, s, 1) + dp.get(i, s, 0)) % MOD)
                # dp[i+1][s][2] = (dp[i][s][2] + dp[i][s][1] + dp[i][s][0]) % MOD
                dp.set(i+1, s, 2, (dp.get(i, s, 2) + dp.get(i, s, 1) + dp.get(i, s, 0)) % MOD)

    # print(dp[N][S][2])
    print(dp.get(N, S, 2))


solve()
