#include <bits/stdc++.h>
using namespace std;
long long a[100] = {};
long long n, mx = 0, mn = 101, c;
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mn) mn = a[i];
    if (a[i] > mx) mx = a[i];
  }
  if ((mx - mn) > c) {
    cout << "NO";
    exit(0);
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) cout << (j % c) + 1 << ' ';
    cout << '\n';
  }
  return 0;
}
