#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[101], mn = INT_MAX, mx = INT_MIN;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    mx = max(a[i], mx), mn = min(mn, a[i]);
  }
  if (mx - k > mn) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    int j = 1, r = 1;
    while (j <= a[i]) {
      if (j > mn + 1) r++;
      cout << r << " ";
      j++;
    }
    cout << endl;
  }
}
