#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using pii = pair<int, int>;
using mii = map<int, int>;
using seti = set<int>;
using vpii = vector<pair<int, int>>;
using pqmx = priority_queue<int>;
using pqmn = priority_queue<int, vector<int>, greater<int>>;
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
template <typename T>
inline int sz(T &&x) {
  return (int)(x).size();
}
template <typename T, typename t>
inline T minm(T &x, t y) {
  if (y < x) x = y;
  return x;
}
template <typename T, typename t>
inline T maxm(T &x, t y) {
  if (y > x) x = y;
  return x;
}
void Main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int _ = 0; _ < (n); ++_) cin >> a[_];
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j)
      if (abs(a[i] - a[j]) > k) {
        cout << "NO\n";
        return;
      }
  cout << "YES\n";
  for (auto &i : (a)) {
    int c = -1;
    for (int j = (0); j < (i); ++j) cout << (++c) % k + 1 << " ";
    cout << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T = 1;
  for (int t = 1; t <= T; ++t) {
    Main();
  }
  return 0;
}
