#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
int n, k, a, m, mm;
vector<int> v;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  m = 1000000000;
  for (unsigned long long i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
    m = min(m, a);
    mm = max(mm, a);
  }
  if (mm - m > k) {
    cout << "NO" << '\n';
    return 0;
  }
  cout << "YES" << '\n';
  for (unsigned long long i = 0; i < n; i++) {
    for (unsigned long long j = 0; j < v[i]; j++) cout << (j % k) + 1 << " ";
    cout << '\n';
  }
  return 0;
}
