#include <bits/stdc++.h>
using namespace std;
int n, k, a[110], b[110][110], f[110][110];
int main() {
  scanf("%d %d", &n, &k);
  for (int i = (1), _b = (n); i <= _b; i++) scanf("%d", &a[i]);
  for (int i = (1), _b = (n); i <= _b; i++)
    for (int j = (1), _b = (a[i]); j <= _b; j++) {
      f[i][j] = j % k;
      if (j % k == 0) f[i][j] = k;
      b[i][f[i][j]]++;
    }
  for (int c = (1), _b = (k); c <= _b; c++)
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (i + 1), _b = (n); j <= _b; j++)
        if (abs(b[i][c] - b[j][c]) > 1) {
          cout << "NO";
          return 0;
        }
  cout << "YES" << endl;
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int j = (1), _b = (a[i]); j <= _b; j++) printf("%d ", f[i][j]);
    printf("\n");
  }
  return 0;
}
