N,S= map(int,input().split())
a_list = list(map(int,input().split()))
# j < S に置いては、dp[i][j]: i番目までの数字を使ってjを作るときに左端の数字
dp = [[[] for _ in range(S+1)] for _ in range(N+1)]
for i in range(1,N+1):
    ai = a_list[i-1]
    for j in range(1,S):
        dpij = []
        if j == ai:
            dpij = [i]
        conj = j - ai
        if conj > 0:
            dpij += dp[i-1][conj]
        dpij += dp[i-1][j]
        dp[i][j] = dpij
            # for ii in range(1,i):
            #     dpij += dp[ii][conj]
            # dp[i][j] += dpij

j = S
ans = 0

for i in range(1,N+1):
    ai = a_list[i-1]
    dpij = []
    if ai == j:
        dpij = [i]
    conj = j - ai
    if conj > 0:    
        dpij = dp[i-1][conj]
    for l in dpij:
        ans += l * (N+1-i)
        ans = ans % 998244353

print(ans)


