#include <bits/stdc++.h>
using namespace std;
bool check(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > peb(n);
  for (int i = 0; i < n; ++i) {
    cin >> peb[i].first;
    peb[i].second = i;
  }
  sort(peb.begin(), peb.end());
  int color = 1;
  int t = peb[0].first + 1;
  int tt = t;
  for (int i = 1; i < n; ++i) {
    if (peb[i].first > t) {
      color += peb[i].first - t;
      t = peb[i].first;
    }
    if (color > k) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  int j = 1;
  sort(peb.begin(), peb.end(), check);
  for (int i = 0; i < n; ++i) {
    t = tt;
    j = 1;
    for (int k = 0; k < peb[i].first; ++k) {
      if (k + 1 <= t) {
        cout << j << " ";
      } else {
        cout << ++j << " ";
      }
    }
    cout << "\n";
  }
  return 0;
}
