#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[101] = {0};
  for (int i = 0; i < n; i++) cin >> arr[i];
  int mn = 1000000;
  int mx = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, arr[i]);
    mx = max(mx, arr[i]);
  }
  int t = mx - mn;
  if (t <= k) {
    cout << "YES" << '\n';
    for (int j = 0; j < n; j++) {
      int posn = 0;
      for (int i = 1; i <= mn; i++, posn++) {
        cout << 1 << " ";
      }
      for (int i = 1; i + posn <= arr[j]; i++) {
        cout << i << " ";
      }
      cout << "\n";
    }
  } else {
    cout << "NO";
  }
  return 0;
}
