#include <bits/stdc++.h>
using namespace std;
inline int ci() {
  register char ch;
  int f = 1;
  while (!isdigit(ch = getchar())) f = ch == '-' ? -1 : 1;
  register int x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (x * 10) + (ch ^ '0');
  return f * x;
}
const int mod = 998244353;
enum { N = 3023 };
long long f[N];
int main() {
  int n = ci(), s = ci();
  long long ans = 0;
  for (register int i = (1); i <= (n); i++) {
    int x = ci();
    ans = (ans + (n - i + 1) * f[s - x]) % mod;
    for (register int j = (s); j >= (x); j--) f[j] = (f[j] + f[j - x]);
    f[x] += i;
  }
  printf("%lld\n", (ans + mod) % mod);
  return 0;
}
