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