#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 3000 + 5;
const long long mo = 998244353;
long long n, s;
long long a[N];
long long dp[N];
long long ans;
int main() {
  int i;
  cin >> n >> s;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (i = 1; i <= n; i++) {
    if (a[i] > s) continue;
    ans = (ans + dp[s - a[i]] * (n - i + 1)) % mo;
    if (a[i] == s) ans = (ans + (n - i + 1) * i % mo) % mo;
    for (int j = s; j > 0; j--) {
      if (j + a[i] < s) dp[j + a[i]] += dp[j];
    }
    dp[a[i]] += i;
  }
  cout << ans << endl;
}
