#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  ;
  int color = 1;
  vector<vector<int>> ans(n);
  for (int i = 0; i < n; ++i) {
    int tmp = 1;
    int cnt = (i == 0 ? a[0].first : a[0].first + 1);
    for (int j = 0; j < a[i].first; ++j) {
      if (j >= cnt) {
        tmp++;
      }
      ans[a[i].second].emplace_back(tmp);
    }
    color = max(color, tmp);
  }
  if (color <= m) {
    cout << "YES"
         << "\n";
    for (auto v : ans) {
      for (int i = 0; i < ((int)(v).size()); ++i) {
        cout << v[i] << (i == ((int)(v).size()) - 1 ? "\n" : " ");
      }
    }
    return;
  }
  cout << "NO"
       << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
