#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
inline T russian(T a, T b, T mod) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = (a + a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return a;
}
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1000000000000000000;
const long long N = 1e6 + 7;
const long long T = 1 << 20;
const long long Hope = 1000000123;
long long n, m, k, q;
long long dp[4000][4000];
long long dp2[4000][4000];
int ans = INF;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 2 * k; j++) dp[i][j] = dp[i - 1][j];
    long long x;
    cin >> x;
    dp[i][x] = (i + dp[i][x]);
    for (int j = x + 1; j < k; j++)
      dp[i][j] = (dp[i][j] + dp[i - 1][j - x]) % mod;
    if (x <= k) dp[i][k] = (dp[i][k] + dp[i - 1][k - x] * (n - i + 1)) % mod;
  }
  cout << dp[n][k] << '\n';
}
