#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, arr[110], mn = 500, mx = -100;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mn = min(mn, arr[i]);
    mx = max(mx, arr[i]);
  }
  if (mx - mn > k)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      int f = 1;
      for (int j = 0; j < arr[i]; j++) {
        cout << f << " ";
        f %= k;
        f++;
      }
      cout << endl;
    }
  }
  return 0;
}
