#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) {
    int n, k, mx = 0, mn = 101, j;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i += 1) {
      cin >> a[i];
      mx = max(mx, a[i]);
      mn = min(mn, a[i]);
    }
    if (mx - mn > k)
      cout << "NO";
    else {
      cout << "YES" << '\n';
      for (int i = 0; i < n; i += 1) {
        for (j = 0; j < a[i] - 1; j++) {
          cout << (j % k) + 1 << " ";
        }
        cout << (j % k) + 1 << '\n';
      }
    }
  }
  return 0;
}
