from numpy import zeros

mod = 998244353


N, S, *A = map(int, open(0).read().split())

dp = zeros(S + 1, dtype="int32")
ans = 0
for i, a in enumerate(A, 1):
    if a <= S:
        dp[a:] += dp[:S + 1 - a]
        dp[a] += i

    ans += dp[-1]
    ans %= mod

print(ans)