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