#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, max, min, rmax, rmin, qmax, qmin, j;
  cin >> n >> k;
  int a[n];
  cin >> a[0];
  max = a[0];
  min = a[0];
  for (i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) max = a[i];
    if (a[i] < min) min = a[i];
  }
  qmax = (max / k);
  qmin = (min / k);
  rmax = (max % k);
  rmin = min % k;
  int flag = 0;
  if (qmax == qmin)
    flag = 1;
  else if (abs(qmax - qmin) == 1) {
    if (rmax <= rmin) flag = 1;
  }
  if (flag == 1) {
    cout << "YES" << endl;
    for (i = 0; i < n; i++) {
      for (j = 1; j <= a[i]; j++) {
        if (j % k == 0)
          cout << k << " ";
        else
          cout << j % k << " ";
      }
      cout << endl;
    }
  } else
    cout << "NO" << endl;
  return 0;
}
