#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j;
  cin >> n >> k;
  int a[105];
  for (i = 0; i < n; i++) cin >> a[i];
  int min = a[0], max = a[0];
  for (i = 0; i < n; i++) {
    if (a[i] > max) max = a[i];
    if (a[i] < min) min = a[i];
  }
  if ((max - min) > k)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (i = 0; i < n; i++) {
      int k1 = 1;
      for (j = a[i]; j > 0; j--) {
        cout << k1 << " ";
        k1++;
        if (k1 > k) k1 = 1;
      }
      cout << "\n";
    }
  }
  return 0;
}
