#include <bits/stdc++.h>
using namespace std;
const int oo = 2e6 + 1001;
const int N = 2e5 + 1001;
const int M = 2010;
int main() {
  int n, m;
  cin >> n >> m;
  int mi = oo, ma = 00;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mi = min(mi, v[i]);
    ma = max(ma, v[i]);
  }
  if (ma - mi > m) return puts("NO"), 0;
  puts("YES");
  for (int x, i = 0; i < n; i++) {
    x = v[i];
    for (int i = 1; i <= x; i++) {
      cout << (!(i % m) ? m : i % m) << " ";
    }
    cout << endl;
  }
  return 0;
}
