#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (a < b) a = b;
}
const double eps = 1e-7;
const int N = 1;
const int M = 200000;
const long long P = 10000000097ll;
const int INF = 0x3f3f3f3f;
int a[110][110];
int main() {
  int i, j, t, k, n, m, v, u, numCase = 0;
  int MAX = -INF, MIN = INF;
  cin >> n >> k;
  for (i = 1; i <= n; ++i) {
    cin >> a[i][0];
    checkmin(MIN, a[i][0]);
    checkmax(MAX, a[i][0]);
  }
  if (MAX - MIN > k) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (i = 1; i <= n; ++i) {
    int num = a[i][0];
    for (j = 1; j <= MIN; ++j) {
      cout << '1' << ' ';
    }
    int delta = num - MIN;
    j = 1;
    while (delta) {
      cout << j++ << ' ';
      delta--;
    }
    cout << endl;
  }
}
