#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
void print() {}
template <class H, class... T>
void print(H&& h, T&&... t) {
  cout << h << " \n"[sizeof...(t) == 0];
  print(forward<T>(t)...);
}
ll dp[3010][3010] = {};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, S;
  cin >> N >> S;
  ll A[3010];
  for (ll i = (0); i < (N); i++) cin >> A[i];
  ll ans = 0;
  for (ll i = (0); i < (N); i++) {
    for (ll j = (0); j < (S + 1); j++) {
      (dp[i + 1][j] += dp[i][j]) %= MOD;
    }
    ans += dp[i + 1][S - A[i]] * (N - i);
    ans %= MOD;
    (dp[i + 1][A[i]] += i + 1) %= MOD;
    for (ll j = (0); j < (S + 1); j++) {
      if (j - A[i] >= 0) (dp[i + 1][j] += dp[i][j - A[i]]) %= MOD;
    }
    if (A[i] == S) {
      ans += (i + 1) * (N - i);
      ans %= MOD;
    }
  }
  print(ans);
}
