#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, k;
struct Pile {
  int w, id;
  int c[N], cn;
  bool operator<(const Pile& rhs) const { return w < rhs.w; }
} a[N];
bool cmpid(const Pile& a, const Pile& b) { return a.id < b.id; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].w);
    a[i].id = i;
  }
  sort(a, a + n);
  int nc = 0;
  for (int i = 0; i < n; i++) {
    while (a[i].cn < a[i].w) {
      nc++;
      if (nc > k) {
        puts("NO");
        return 0;
      }
      int rnd = 1;
      if (i == 0) rnd = a[i].w;
      while (rnd--) {
        for (int j = i; j < n; j++) {
          a[j].c[a[j].cn++] = nc;
        }
      }
      if (i == 0) {
        for (int j = i + 1; j < n; j++) {
          if (a[j].cn < a[j].w) a[j].c[a[j].cn++] = nc;
        }
      }
    }
  }
  sort(a, a + n, cmpid);
  puts("YES");
  for (int i = 0; i < n; i++) {
    printf("%d", a[i].c[0]);
    for (int j = 1; j < a[i].cn; j++) {
      printf(" %d", a[i].c[j]);
    }
    puts("");
  }
  return 0;
}
