#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int b[N][N], a[N], n, k;
bool kt(int* a) {
  for (int i = 1; i <= n; ++i)
    if (a[i]) return true;
  return false;
}
bool check(int i, int j) {
  for (int l = 1; l <= n; ++l)
    if (abs(b[l][j] - b[i][j] - 1) > 1) return false;
  return true;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  while (kt(a)) {
    bool f = false;
    for (int i = 1; i <= n; ++i) {
      if (a[i])
        for (int j = 1; j <= k; ++j) {
          if (!check(i, j)) continue;
          f = true;
          b[i][j]++;
          a[i]--;
          break;
        }
    }
    if (!f) {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j)
      for (int t = 1; t <= b[i][j]; ++t) printf("%d ", j);
    printf("\n");
  }
  return 0;
}
