# numpyで書換えた
import numpy as np

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    A = tuple(map(int, input().split()))

    DP = np.array([[[0] * 3 for _ in range(S + 1)] for _ in range(N + 1)], dtype = np.int64)
    DP[0, 0, 0] = 1

    for i in range(N):
        DP[i + 1, :, :] = DP[i, :, :] 
        DP[i + 1, 0, 1] = DP[i, 0, 0] + DP[i, 0, 1]
        a = A[i]
        if a > S:
            DP[i + 1, 1:, 1] = DP[i, 1:, 1] #以前から合計jになっている場合のみOK
        else:
            DP[i + 1, 1:a, 1] = DP[i, 1:a, 1] #以前から合計jになっている場合のみOK
            DP[i + 1, a: S + 1, 1] = (DP[i, a: S + 1, 1] + DP[i, :S - a + 1, 0] + DP[i, :S - a + 1, 1]) % MOD
            
        DP[i + 1, S, 2] = (DP[i, S, 1] + DP[i, S, 2])
        if a <= S:
            DP[i + 1, S, 2] += DP[i, S - a, 0] + DP[i, S - a, 1]
        DP[i + 1, S, 2] %= MOD

    print (DP[N, S, 2])

    # for i in range(N + 1):
    #     print (DP[i])

if __name__ == '__main__':
    main()