#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[100];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int> > b(100);
  for (int i = 0; i < k; i++) {
    int maxc = 0, minc = 100;
    for (int j = 0; j < n; j++) {
      int num = a[j] / k;
      if (a[j] % k > 0 && a[j] % k > i) ++num;
      for (int p = 0; p < num; ++p) b[j].push_back(i + 1);
      maxc = max(maxc, num);
      minc = min(minc, num);
    }
    if (maxc - minc > 1) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < a[i]; j++) cout << b[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
