#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, s, minn = 0, maxn = 0, mink, maxk;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > a[maxn]) maxn = i;
    if (a[i] < a[minn]) minn = i;
  }
  if (a[maxn] - a[minn] > k)
    cout << "NO";
  else {
    cout << "YES";
    for (i = 1; i <= n; i++) {
      cout << endl;
      for (j = 0; j < a[i - 1]; j++) cout << (j % k) + 1 << " ";
    }
  }
}
