#include <bits/stdc++.h>
using namespace std;
static int n, k;
static vector<int> v;
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    v.clear();
    v.resize(n);
    int maxinum = INT_MIN, minium = INT_MAX;
    for (int i = 0; i < n; i++) {
      scanf("%d", &v[i]);
      maxinum = max(v[i], maxinum);
      minium = min(v[i], minium);
    }
    if (maxinum - minium > k) {
      printf("NO\n");
    } else {
      printf("YES\n");
      for (int i = 0; i < n; i++) {
        for (int j = 1; j <= v[i] && j <= k; j++) printf("%d ", j);
        if (k < v[i]) {
          int cnt = 0;
          while (cnt < v[i] - k) {
            for (int j = 1; j <= k; j++) {
              printf("%d ", j);
              ++cnt;
              if (cnt == v[i] - k) break;
            }
          }
        }
        printf("\n");
      }
    }
  }
  return 0;
}
