#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int mx = -1, mn = INT_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, x = 1;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  if (mx - k > mn) {
    cout << "NO";
    return 0;
  } else {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      x = 1;
      for (int j = 0; j < a[i]; j++) {
        cout << x++ << " ";
        if (x > k) x = 1;
      }
      cout << endl;
    }
  }
  return 0;
}
