#include <bits/stdc++.h>
using namespace std;
long long c[1000], k, ans[400][400], b[1000], n, i, a[400], j, l, p, mas[400],
    t, lik, m;
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    p = 1;
    for (j = 1; j <= a[i]; j++) {
      if (p > m) p = 1;
      ans[i][j] = p;
      p++;
    }
  }
  for (i = 1; i <= n; i++) {
    memset(b, 0, sizeof(b));
    for (j = 1; j <= a[i]; j++) b[ans[i][j]]++;
    for (j = i + 1; j <= n; j++) {
      memset(c, 0, sizeof(c));
      for (k = 1; k <= a[j]; k++) c[ans[j][k]]++;
      for (k = 1; k <= m; k++)
        if (abs(c[k] - b[k]) > 1) {
          cout << "NO";
          return 0;
        }
    }
  }
  cout << "YES" << endl;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= a[i]; j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
