#include<cstdio>
#include<vector>
#include<utility>
#define MOD 998244353

using namespace std;

int n, s;
int a[3003];

struct wtf {
  vector<int> v1, v2, v3;
  int c;
};

wtf dac(int l, int r) {
  vector<int> v1(s+1);
  vector<int> v2(s+1);
  vector<int> v3(s+1);
  int c = 0;
  if (l + 1 == r) {
    if (a[l] <= s) {
      v1[a[l]] = l + 1;
      v2[a[l]] = n - l;
      v3[a[l]] = 1;
      c = 1ll * v1[s] * v2[s] % MOD;
    }
    return {v1, v2, v3, c};
  }
  int m = (l + r) / 2;
  wtf wtf1 = dac(l, m);
  wtf wtf2 = dac(m, r);
  for (int i = 1; i <= s; i++) {
    v1[i] = wtf1.v1[i] + wtf2.v1[i];
    for (int j = 1; j < i; j++) {
      v1[i] += 1ll * wtf1.v1[j] * wtf2.v3[i - j] % MOD;
      v1[i] %= MOD;
    }
  }
  for (int i = 1; i <= s; i++) {
    v2[i] = wtf1.v2[i] + wtf2.v2[i];
    for (int j = 1; j < i; j++) {
      v2[i] += 1ll * wtf2.v2[j] * wtf1.v3[i - j] % MOD;
      v2[i] %= MOD;
    }
  }
  for (int i = 1; i <= s; i++) {
    v3[i] = wtf1.v3[i] + wtf2.v3[i];
    for (int j = 1; j < i; j++) {
      v3[i] += 1ll * wtf1.v3[j] * wtf2.v3[i - j] % MOD;
      v3[i] %= MOD;
    }
  }
  for (int i = 0; i <= s; i++) {
    c += 1ll * wtf1.v1[i] * wtf2.v2[s - i] % MOD;
    c %= MOD;
  }
  return {v1, v2, v3, (0ll + wtf1.c + wtf2.c + c) % MOD};
}

int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  printf("%d\n", dac(0, n).c);
}
