#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int mn, mx;
  int c[k][n];
  memset(c, 0, sizeof(c));
  bool flg = false;
  int lm = 0;
  for (int i = 0; i < n; i++) lm = max(lm, a[i]);
  for (int i = 0; i < lm; i++) {
    flg = false;
    for (int j = 0; j < k; j++) {
      mn = 101;
      mx = 0;
      for (int r = 0; r < n; r++) {
        if (a[r]) {
          mn = min(mn, c[j][r] + 1);
          mx = max(mx, c[j][r] + 1);
        } else {
          mn = min(mn, c[j][r]);
          mx = max(mx, c[j][r]);
        }
      }
      if ((abs(mn - mx)) <= 1) {
        flg = true;
        for (int r = 0; r < n; r++) {
          if (a[r]) {
            c[j][r] += 1;
            a[r] = a[r] - 1;
          }
        }
        break;
      }
    }
    if (!flg) break;
  }
  if (!flg)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int j = 0; j < n; j++) {
      vector<int> tp;
      for (int i = 0; i < k; i++) {
        if (c[i][j]) {
          int cnt = c[i][j];
          while (cnt--) {
            tp.push_back(i + 1);
          }
        }
      }
      for (int i = 0; i < tp.size(); i++) {
        if (i == tp.size() - 1)
          cout << tp[i];
        else
          cout << tp[i] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
