#include <bits/stdc++.h>
using namespace std;
using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr int MOD = 998244353;
LL rev(const VVLL &dp, VVLL &memo, const VI &a, int pos, int cnt) {
  int n = dp.size();
  if (pos < 0 || dp[pos][cnt] == 0) return 0;
  if (memo[pos][cnt] > -1) return memo[pos][cnt];
  LL ret = 0;
  if (cnt == a[pos]) {
    ret += (1LL * (pos + 1)) % MOD;
  }
  return ((memo[pos][cnt] = ret + (rev(dp, memo, a, pos - 1, cnt)) % MOD) +
          (rev(dp, memo, a, pos - 1, cnt - a[pos]) * (n - pos)) % MOD) %
         MOD;
}
void solve() {
  int n, s;
  cin >> n >> s;
  VI a(n);
  for (int i = int(0); i < int(n); i++) cin >> a[i];
  VI ru(n + 1);
  for (int i = int(0); i < int(n); i++) ru[i + 1] = ru[i] + a[i];
  VVLL dp(n, VLL(3000 + 1));
  dp[0][a[0]] = 1;
  for (int i = int(1); i < int(n); i++) {
    dp[i][a[i]] = 1;
    for (int j = int(a[i]); j < int(3000 + 1); j++) {
      for (int k = int(0); k < int(i); k++) {
        dp[i][j] += dp[k][j - a[i]];
        if (dp[i][j] >= MOD) dp[i][j] -= MOD;
      }
    }
  }
  VVLL memo(n, VLL(3000 + 1, -1));
  LL ans = rev(dp, memo, a, n - 1, s);
  cout << ans << endl;
  do {
  } while (0);
  for (int i = int(0); i < int(n); i++) {
    for (int j = int(0); j < int(s + 1); j++) cout << dp[i][j] << " ";
    cout << endl;
  }
}
signed main() {
  solve();
  return 0;
}
