#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long ppow(long long a, long long b, long long mod) {
  a %= mod;
  long long ans = 1 % mod;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long readdd() {
  long long x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return f * x;
}
void printtt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) printtt(x / 10);
  putchar(x % 10 + '0');
}
bool addd(long long a, long long b) { return a > b; };
const long long maxm = 3e3 + 5;
const long long mod = 998244353;
long long d[maxm];
long long a[maxm];
signed main() {
  long long n, s;
  cin >> n >> s;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (s - a[i] > 0) {
      ans = (ans + d[s - a[i]] * (n - i + 1) % mod) % mod;
    } else if (s == a[i]) {
      ans = (ans + i * (n - i + 1) % mod) % mod;
    }
    for (long long j = s; j >= a[i]; j--) {
      d[j] = d[j] + d[j - a[i]];
    }
    d[a[i]] += i;
  }
  cout << ans << endl;
  return 0;
}
