P = 998244353

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

dp = [[[0]*3 for i in range(S+1)] for _ in range(N)]

dp[0][0][0] = 1
dp[0][0][1] = 1
if A[0] <= S:
    dp[0][A[0]][1] = 1

for i in range(1, N):
    dp[i][0][0] = 1
    dp[i][0][1] = dp[i-1][0][1] + 1
    dp[i][S][2] = dp[i-1][S][2] + dp[i-1][S][1]
    if A[i] == S:
        dp[i][S][2] += 1 + dp[i-1][0][1]
        dp[i][S][1] += dp[i-1][0][1] + 1
    elif A[i] < S:
        dp[i][A[i]][1] += 1 + dp[i-1][0][1]
    for j in range(1, S+1):
        dp[i][j][1] += dp[i-1][j][1]
        if j + A[i] < S:
            dp[i][j+A[i]][1] += dp[i-1][j][1]
        elif j + A[i] == S:
            dp[i][S][2] += dp[i-1][j][1]
            dp[i][S][1] += dp[i-1][j][1]
        dp[i][j][0] %= P
        dp[i][j][1] %= P
        dp[i][j][2] %= P

print(dp[N-1][S][2])