#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long mod = 1000000007;
const long long INF = 1e15;
vector<long long> dx = {1, 0, -1, 0};
vector<long long> dy = {0, 1, 0, -1};
long long dp[3001][3001];
int main() {
  long long N, S;
  cin >> N >> S;
  vector<long long> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long x = d.at(i);
    if (x == S) {
      ans = (ans + (i + 1) * (N - i)) % MOD;
      dp[i][x]++;
    } else if (x < S) {
      dp[i][x]++;
      if (i != 0)
        for (int j = 0; j < i; j++) {
          long long XX = (j + 1) * (N - i) % mod;
          ans = (ans + XX * dp[j][S - x]) % MOD;
          for (long long k = S - x; k >= 1; k--) {
            dp[j][k + x] = (dp[j][k + x] + dp[j][k]) % MOD;
          }
        }
    }
  }
  cout << ans << endl;
}
