#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAXN = 105;
int n, k, a[MAXN], mi = INF, ma = -INF;
int main(int argc, char const *argv[]) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    mi = min(mi, a[i]), ma = max(ma, a[i]);
  }
  if (ma - mi > k) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  for (int i = 0; i < n; ++i) {
    int num = 1;
    for (int j = 0; j < mi; ++j) printf("%d ", num);
    num++, a[i] -= mi;
    if (a[i] > 0) printf("1 ");
    for (int j = 0; j < a[i] - 1; ++j) printf("%d ", num++);
    printf("\n");
  }
  return 0;
}
