#include <bits/stdc++.h>
using namespace std;
const int N = 3003;
set<pair<int, int> > g[N];
set<pair<int, int> >::iterator it1, it2;
int n, s;
int ara[N];
pair<int, int> isIt(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first || a.second == b.second) return (make_pair(-1, -1));
  return make_pair(min(a.first, b.first), max(a.second, b.second));
}
long long int mod = 998244353;
int main() {
  int i, j, k, l;
  pair<int, int> a, b, c;
  cin >> n >> s;
  for (i = 1; i <= n; i++) {
    cin >> ara[i];
    g[ara[i]].insert(make_pair(i, i));
  }
  for (i = 2; i <= s; i++) {
    for (j = 1; j <= i / 2; j++) {
      for (it1 = g[j].begin(); it1 != g[j].end(); it1++) {
        a = *it1;
        for (it2 = g[i - j].begin(); it2 != g[i - j].end(); it2++) {
          b = *it2;
          c = isIt(a, b);
          if (c.first != -1) {
            g[i].insert(c);
          }
        }
      }
    }
  }
  long long int ss = 0;
  for (it1 = g[s].begin(); it1 != g[s].end(); it1++) {
    a = *it1;
    ss = (ss + (a.first * (n - a.second + 1)) % mod) % mod;
  }
  cout << ss << '\n';
  return 0;
}
