#include <bits/stdc++.h>
using namespace std;
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  fast_io();
  long long n, k;
  cin >> n >> k;
  long long a[n];
  long long maxi = INT_MIN;
  long long mini = INT_MAX;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
    mini = min(mini, a[i]);
  }
  if ((maxi - mini) <= k) {
    cout << "YES\n";
    for (long long i = 0; i < n; i++) {
      long long temp = 1;
      for (long long j = 1; j <= a[i]; j++) {
        if (j <= mini + 1)
          cout << "1 ";
        else {
          temp++;
          cout << temp << " ";
        }
      }
      cout << endl;
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
