#include <bits/stdc++.h>
using namespace std;
int n, k, *mx, *mn;
int main() {
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  mx = max_element(a, a + n);
  mn = min_element(a, a + n);
  if ((*mx - *mn) > k) {
    cout << "NO";
    return 0;
  } else
    cout << "YES"
         << "\n";
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < a[j] && i < *mn; i++) cout << (i ? " " : "") << "1";
    for (int i = 0; i < (a[j] - *mn); i++) cout << " " << i + 1;
    if ((j + 1) < n) cout << "\n";
  }
}
