# https://atcoder.jp/contests/abc159/submissions/11139734



def main():

    MOD = 998244353



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

    *A, = list(map(int, input().split()))



    ans = 0

    dp = [0] * (S + 1)

    for i, a in enumerate(A, start=1):

        dp[0] = i  # i以前の(i+1)通りの起点がある（以後未取得）

        ans += dp[S]  # aを取らずにclose

        if S >= a:

            ans += dp[S - a]  # aを取ってclose

        ans %= MOD

        for s in reversed(list(range(a, S + 1))):

            dp[s] += dp[s - a]

            dp[s] %= MOD



    print(ans)





if __name__ == '__main__':

    main()

def main():

    MOD = 998244353



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

    *A, = list(map(int, input().split()))



    dp = [0] * (S + 1)

    ans = 0

    for x in A:

        dp[0] += 1

        for j in range(S, x - 1, -1):

            dp[j] = (dp[j] + dp[j - x]) % MOD

        ans = (ans + dp[S]) % MOD

    print(ans)





if __name__ == '__main__':

    main()

# https://atcoder.jp/contests/abc159/submissions/11139734
def main():
    MOD = 998244353
    N, S = list(map(int, input().split()))
    (*A,) = list(map(int, input().split()))
    ans = 0
    dp = [0] * (S + 1)
    for i, a in enumerate(A, start=1):
        dp[0] = i  # i以前の(i+1)通りの起点がある（以後未取得）
        ans += dp[S]  # aを取らずにclose
        if S >= a:
            ans += dp[S - a]  # aを取ってclose
        ans %= MOD
        for s in reversed(list(range(a, S + 1))):
            dp[s] += dp[s - a]
            dp[s] %= MOD
    print(ans)


if __name__ == "__main__":
    main()

def main():
    MOD = 998244353
    N, S = list(map(int, input().split()))
    (*A,) = list(map(int, input().split()))
    dp = [0] * (S + 1)
    ans = 0
    for x in A:
        dp[0] += 1
        for j in range(S, x - 1, -1):
            dp[j] = (dp[j] + dp[j - x]) % MOD
        ans = (ans + dp[S]) % MOD
    print(ans)


if __name__ == "__main__":
    main()

-# https://atcoder.jp/contests/abc159/submissions/11139734 +    dp = [0] * (S + 1) -    dp = [0] * (S + 1) -    for i, a in enumerate(A, start=1): -        dp[0] = i  # i以前の(i+1)通りの起点がある（以後未取得） -        ans += dp[S]  # aを取らずにclose -        if S >= a: -            ans += dp[S - a]  # aを取ってclose -        ans %= MOD -        for s in reversed(list(range(a, S + 1))): -            dp[s] += dp[s - a] -            dp[s] %= MOD +    for x in A: +        dp[0] += 1 +        for j in range(S, x - 1, -1): +            dp[j] = (dp[j] + dp[j - x]) % MOD +        ans = (ans + dp[S]) % MOD