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