fun main(args: Array<String>) {
    val mod = 998244353L

    val (N, S) = readInputLine().split(" ").map { it.toInt() }
    val AArr = readInputLine().split(" ").map { it.toInt() }.toIntArray()

    val dp = Array(N + 1) { Array(S + 3001) { LongArray(3) } }

    dp[0][0][0] = 1L

    for (i in 0 until N) {
        for (j in 0..S) {
            dp[i + 1][j][0] += dp[i][j][0]
            dp[i + 1][j][0] %= mod
            dp[i + 1][j][1] += dp[i][j][0] + dp[i][j][1]
            dp[i + 1][j][1] %= mod
            dp[i + 1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]
            dp[i + 1][j][2] %= mod

            dp[i + 1][j + AArr[i]][1] += dp[i][j][0] + dp[i][j][1]
            dp[i + 1][j + AArr[i]][1] %= mod
            dp[i + 1][j + AArr[i]][2] += dp[i][j][0] + dp[i][j][1]
            dp[i + 1][j + AArr[i]][2] %= mod
        }
    }

    println(dp[N][S][2])
}

fun readInputLine(): String {
    return readLine()!!
}
