#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 11, inf = 1e9;
;
pair<int, int> a[105];
vector<int> ans[105];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  if (a[n].first - a[1].first > k) {
    cout << "NO";
    return 0;
  }
  int m = a[1].first;
  for (int i = 1; i <= n; ++i) {
    a[i].first -= m;
    for (int j = 1; j <= m; ++j) ans[a[i].second].push_back(1);
  }
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (a[j].first > 0) {
        ans[a[j].second].push_back(i);
        a[j].first--;
      }
    }
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; ++i, cout << endl)
    for (int j = 0; j < ans[i].size(); ++j) cout << ans[i][j] << ' ';
  return 0;
}
