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