# https://drken1215.hatenablog.com/entry/2020/03/22/224200

def main():
    import sys
    input = sys.stdin.readline

    MOD = 998244353

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

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

    for i, a in enumerate(A, start=1):
        for j in range(S + 1):
            bf = dp[i - 1][j]
            not_opened = bf[0]
            opened = bf[1]
            closed = bf[2]

            curr = dp[i][j]

            curr[0] = (curr[0] + not_opened) % MOD
            curr[1] = (curr[1] + opened) % MOD
            curr[2] = (curr[2] + closed) % MOD

            if (nj := j + a) <= S:
                dp[i][nj][1] = (dp[i][nj][1] + not_opened * i + opened) % MOD
                dp[i][nj][2] = (dp[i][nj][2] + not_opened * i * (N - i + 1) + opened * (N - i + 1)) % MOD

    ans = dp[-1][-1][2]
    print(ans)


if __name__ == '__main__':
    main()
