import numpy as np

MOD = 998244353

def main():

    n, s = list(map(int, input().split()))

    a = list(map(int, input().split()))

    dp = [np.zeros(s+1, dtype=np.int64) for i in range(n+1)]

    ans = 0

    for i in range(n):

        if a[i] <= s:

            dp[i+1][a[i]:] = dp[i][:-a[i]]

            dp[i+1][a[i]] += i+1

        dp[i+1][:s] += dp[i][:s]

        dp[i+1][dp[i+1] >= MOD] -= MOD

        ans += dp[i+1][s] * (n-i)

        ans %= MOD

#        print(dp[i+1], ans)

    print(ans)



if __name__ == "__main__":

    main()
import numpy as np



MOD = 998244353



def main():

    n, s = list(map(int, input().split()))

    a = list(map(int, input().split()))

    dp = np.zeros((n+1, s+1), dtype=np.int64)

    for i, v in enumerate(a):

        dp[i][0] += 1

        dp[i+1] += dp[i]

        if v <= s:

            dp[i+1][v:] += dp[i][:-v]

        dp[i+1] %= MOD

    ans = 0

    for i in range(n+1):

        ans += dp[i][s]

        ans %= MOD

    print(ans)



if __name__ == "__main__":

    main()

import numpy as np

MOD = 998244353


def main():
    n, s = list(map(int, input().split()))
    a = list(map(int, input().split()))
    dp = [np.zeros(s + 1, dtype=np.int64) for i in range(n + 1)]
    ans = 0
    for i in range(n):
        if a[i] <= s:
            dp[i + 1][a[i] :] = dp[i][: -a[i]]
            dp[i + 1][a[i]] += i + 1
        dp[i + 1][:s] += dp[i][:s]
        dp[i + 1][dp[i + 1] >= MOD] -= MOD
        ans += dp[i + 1][s] * (n - i)
        ans %= MOD
    #        print(dp[i+1], ans)
    print(ans)


if __name__ == "__main__":
    main()

import numpy as np

MOD = 998244353


def main():
    n, s = list(map(int, input().split()))
    a = list(map(int, input().split()))
    dp = np.zeros((n + 1, s + 1), dtype=np.int64)
    for i, v in enumerate(a):
        dp[i][0] += 1
        dp[i + 1] += dp[i]
        if v <= s:
            dp[i + 1][v:] += dp[i][:-v]
        dp[i + 1] %= MOD
    ans = 0
    for i in range(n + 1):
        ans += dp[i][s]
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

-    dp = [np.zeros(s + 1, dtype=np.int64) for i in range(n + 1)] +    dp = np.zeros((n + 1, s + 1), dtype=np.int64) +    for i, v in enumerate(a): +        dp[i][0] += 1 +        dp[i + 1] += dp[i] +        if v <= s: +            dp[i + 1][v:] += dp[i][:-v] +        dp[i + 1] %= MOD -    for i in range(n): -        if a[i] <= s: -            dp[i + 1][a[i] :] = dp[i][: -a[i]] -            dp[i + 1][a[i]] += i + 1 -        dp[i + 1][:s] += dp[i][:s] -        dp[i + 1][dp[i + 1] >= MOD] -= MOD -        ans += dp[i + 1][s] * (n - i) +    for i in range(n + 1): +        ans += dp[i][s] -    #        print(dp[i+1], ans)