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