#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if ((a[i] - a[j]) > k) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES"
       << "\n";
  for (int i = 0; i < n; i++) {
    int x = a[i] / k;
    for (int j = 0; j < x; j++) {
      for (int l = 1; l <= k; l++) cout << l << " ";
    }
    for (int l = 1; l <= (a[i] % k); l++) cout << l << " ";
    cout << "\n";
  }
  return 0;
}
