#include <bits/stdc++.h>
using namespace std;
const long MOD = (long)1e9 + 7;
long long const MAXN = 16001;
long long a[100];
vector<long long> g[100];
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long mi = a[0];
  long long ma = a[0];
  for (int i = 0; i < n; i++) {
    mi = min(mi, a[i]);
    ma = max(ma, a[i]);
  }
  if (ma - mi > k) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    long long m = a[i] % k;
    for (int j = 0; j < k; j++) {
      if (j < m) {
        cout << j + 1 << " ";
      }
      for (int kk = 0; kk < a[i] / k; kk++) cout << j + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
