#include <bits/stdc++.h>
using namespace std;
long long n, p;
long long a[4000];
long long barket[4000];
long long ans;
signed main() {
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) {
    if (a[i] > p) continue;
    (ans += (n - i + 1ll) * barket[p - a[i]]) %= 998244353;
    if (a[i] == p) (ans += (n - i + 1ll) * i) %= 998244353;
    for (long long j = p; j >= a[i]; j--) {
      barket[j] += barket[j - a[i]];
    }
    barket[a[i]] += i;
  }
  cout << ans << endl;
  return 0;
}
