# DP tabelを3つに分けた

import numpy as np

def main():
    MOD = 998244353

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

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

    DP0[0, 0] = 1

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

        DP2[i + 1, S] = (DP1[i, S] + DP2[i, S])
        if a <= S:
            DP2[i + 1, S] += DP0[i, S - a] + DP1[i, S - a]
        DP2[i + 1, S] %= MOD

    print (DP2[N, S])

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

if __name__ == '__main__':
    main()