#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, a[101] = {0}, i, minn = 10000, b[101][101] = {0}, k, j;
  cin >> n >> k;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    minn = min(minn, a[i]);
  }
  for (i = 1; i <= n; i++) {
    if (a[i] > minn)
      b[i][1] = minn + 1;
    else
      b[i][1] = minn;
    a[i] -= b[i][1];
  }
  for (i = 1; i <= n; i++)
    for (j = 2; j - 1 <= a[i]; j++) b[i][j] = 1;
  for (i = 1; i < 101; i++)
    for (j = 1; j < 101; j++)
      if (b[i][j] > 0 && k < j) {
        cout << "NO";
        return 0;
      }
  cout << "YES"
       << "\n";
  for (i = 1; i <= n; i++) {
    for (j = 1; j < 101; j++)
      for (int l = 1; l <= b[i][j]; l++) cout << j << " ";
    cout << "\n";
  }
}
