#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9;
const int MIN = -MAX;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int _T = 1;
  for (int _t = 1; _t <= _T; _t++) {
    int n;
    int k;
    int max = MIN;
    int min = MAX;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      max = std::max(max, a[i]);
      min = std::min(min, a[i]);
    }
    int req = (max - (min + 1)) + 1;
    if (req > k) {
      cout << "NO\n";
      goto outer;
    }
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      int now = 1;
      for (int j = 0; j < min + 1 && a[i] > 0; j++) {
        cout << now << " ";
        a[i]--;
      }
      now = 2;
      for (int j = a[i]; j > 0; j--, now++) {
        cout << now << " ";
      }
      cout << "\n";
    }
  outer:;
  }
  return 0;
}
