#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int pebs[n];
  for (int i = 0; i < n; i++) {
    cin >> pebs[i];
  }
  bool no = false;
  int mi = 10000;
  int ma = -1;
  for (int i = 0; i < n; i++) {
    mi = min(mi, pebs[i]);
    ma = max(ma, pebs[i]);
  }
  if (abs(mi - ma) > k) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < pebs[i]; j++) {
        cout << (j % (k)) + 1 << " ";
      }
      cout << endl;
    }
  }
}
