#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, l = 1000, m = 0;
  cin >> n >> k;
  int a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
    l = min(l, a[i]);
  }
  if (m - l > k) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < a[i]; j++) {
      ((j + 1) % k) ? cout << (j + 1) % k : cout << k;
      cout << " ";
    }
    cout << endl;
  }
}
