#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k, minn = INT_MAX, maxx = INT_MIN;
  cin >> n >> k;
  int pile[n];
  for (int i = 0; i < n; i++) {
    cin >> pile[i];
    minn = min(minn, pile[i]);
    maxx = max(maxx, pile[i]);
  }
  if ((maxx - minn) > k)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < pile[i]; j++) {
        cout << 1 + (j % k) << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
