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