#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long mod = 998244353;
long long ksm(long long a, long long b) {
  long long ans = 1LL;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long dp[N];
int a[N];
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == m)
      ans = (ans + 1LL * i * (n - i + 1) % mod) % mod;
    else if (m > a[i])
      ans = (ans + dp[m - a[i]] * (n - i + 1) % mod) % mod;
    for (int j = m; j >= a[i]; j--) {
      dp[j] = (dp[j] + dp[j - m]) % mod;
      if (j == a[i]) dp[j] = (dp[j] + i) % mod;
    }
  }
  printf("%lld\n", ans);
}
int main() {
  solve();
  return 0;
}
