#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
double pi = 2 * acos(0.0);
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first) < (b.first);
}
long long power(long long a, long long b) {
  long long p = 1;
  for (long long i = 1; i <= b; i++) p *= a;
  return p;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
void bfs(map<long long, vector<long long> > &g, long long src,
         vector<long long> &c) {
  queue<long long> q;
  map<long long, long long> p;
  q.push(src);
  p[src] = src;
  c[src] = 1;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    long long i = 1;
    for (auto v : g[u]) {
      if (c[v] == -1) {
        q.push(v);
        p[v] = u;
        if (i == c[u] || i == c[p[u]]) i++;
        if (i == c[u] || i == c[p[u]]) i++;
        c[v] = i;
        i++;
      }
    }
  }
}
long long dp[105][100005], a[105], k, n;
long long fun() {
  long long i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= k; j++) {
      if (i == 0) {
        if (j == 0)
          dp[i][j] = 1;
        else
          dp[i][j] = 0;
      } else {
        dp[i][j] = (mod + dp[i][j - 1] % mod + dp[i - 1][j] % mod -
                    ((j - a[i] - 1 >= 0) ? dp[i - 1][j - a[i] - 1] : 0)) %
                   mod;
      }
    }
  }
  return dp[k][n];
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cout.tie(NULL);
  ;
  long long i, j;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  cout << fun() << endl;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= a[i]; j++) cout << dp[i][j] << " ";
    cout << endl;
  }
  return 0;
}
