#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;
const int M = 998244353;
int dp[3007], noms[3007];
vector<pair<int, int> > V[3007];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(0);
  int n, s;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    cin >> noms[i];
  }
  dp[0] = 1;
  V[0].push_back({n + 1, 1});
  int ans = 0;
  for (int j = 1; j <= n; j++) {
    int x = noms[j];
    if (x > s) continue;
    for (auto y : V[s - x]) {
      ans = (ans + (LL(min(y.first, j)) * (n - j + 1)) % M * LL(y.second)) % M;
    }
    for (int i = s; i >= x; i--) {
      dp[i] += dp[i - x];
      if (dp[i] >= M) dp[i] -= M;
      int m = V[i].size();
      V[i].resize(m + V[i - x].size());
      for (int k = m; k < int(V[i].size()); k++) {
        V[i][k] = {min(V[i - x][k - m].first, j), V[i - x][k - m].second};
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
