#include <bits/stdc++.h>
using namespace std;
long long int num = pow(10, 9) + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int c[n];
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  long long int max_diff = -1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; j++) {
      if (abs(c[i] - c[j]) > max_diff) max_diff = abs(c[i] - c[j]);
    }
  }
  if (max_diff > k) {
    cout << "NO";
  } else {
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 1; j <= c[i]; j++) {
        if (j % k == 0)
          cout << k << " ";
        else
          cout << j % k << " ";
      }
      cout << endl;
    }
  }
}
