#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using cd = complex<double>;
ll o[(ll)(3e5 + 7)], d[(ll)(3e5 + 7)];
int main() {
  int n, k;
  cin >> n >> k;
  int ar[n];
  vector<int> vv[n];
  for (ll i = 0; i < n; i++) {
    cin >> ar[i];
    for (int j = 0; j < ar[i]; j++) {
      vv[i].push_back((j % k) + 1);
    }
  }
  sort(ar, ar + n);
  bool fl = 1;
  for (int i = 0; i < k; i++) {
    int mi = ar[0] / (k) + (i < (ar[0] % k)),
        ma = ar[n - 1] / (k) + (ar[n - 1] % k > i);
    if (ma - mi > 1) {
      fl = 0;
    }
  }
  if (!fl) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      for (int x : vv[i]) {
        cout << x << " ";
      }
      cout << "\n";
    }
  }
}
