#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], c[N][N];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int mn = a[0], mx = a[0];
  for (int i = 0; i < n; ++i) {
    if (a[i] < mn) mn = a[i];
    if (a[i] > mx) mx = a[i];
  }
  int d = mx - mn;
  if (d > k) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= mn; ++j) {
      c[i][j] = 1;
    }
    int t = 2;
    for (int j = mn + 1; j < a[i]; ++j) {
      c[i][j] = t;
      ++t;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < a[i]; ++j) {
      if (j > 0) putchar(' ');
      printf("%d", c[i][j]);
    }
    putchar('\n');
  }
  return 0;
}
