#include <bits/stdc++.h>
using namespace std;
const int maxn = 124;
int m, n, brd[maxn][maxn], minn, maxx;
bool solve() {
  for (int i = 0; i < m; i++) {
    int len = min(minn, brd[i][0]), num = 2, j;
    for (j = 1; j <= minn; j++) brd[i][j] = 1;
    while (j <= brd[i][0]) {
      brd[i][j] = num++;
      j++;
    }
  }
  return true;
}
int main() {
  while (~scanf("%d%d", &m, &n)) {
    minn = 0x7f7f7f7f;
    maxx = 0;
    memset(brd, 0, sizeof(brd));
    for (int i = 0; i < m; i++) {
      scanf("%d", &brd[i][0]);
      minn = min(minn, brd[i][0]);
      maxx = max(maxx, brd[i][0]);
    }
    minn++;
    if (maxx - minn + 1 > n) {
      printf("NO\n");
      continue;
    }
    solve();
    printf("YES\n");
    for (int i = 0; i < m; i++) {
      for (int j = 1; j <= brd[i][0]; j++) {
        if (j > 1) printf(" ");
        printf("%d", brd[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
