#include <bits/stdc++.h>
using namespace std;
void HoH() {
  ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
}
int main() {
  HoH();
  int n, k;
  cin >> n >> k;
  int m = INT_MIN, s = INT_MAX;
  int x;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    m = max(m, a[i]), s = min(s, a[i]);
  }
  if (k + s >= m) {
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 1; j <= s; j++) {
        if (j % k == 0) {
          cout << k << " ";
        } else if (j % k != 0) {
          cout << (j % (k)) << " ";
        } else
          cout << j << " ";
      }
      for (int j = 1; j <= a[i] - s; j++) {
        if (j % k == 0) {
          cout << k << " ";
        } else if (j % k != 0) {
          cout << (j % (k)) << " ";
        } else
          cout << j << " ";
      }
      cout << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
