#include <bits/stdc++.h>
using namespace std;
const int LEN = 101;
const int INF = 0x3f3f3f3f;
vector<int> ans[LEN];
int main() {
  int n, k, a[LEN], Min, Max;
  while (cin >> n >> k) {
    for (int i = 0; i < LEN; i++) ans[i].clear();
    Min = INF;
    Max = -INF;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      Min = min(Min, a[i]);
      Max = max(Max, a[i]);
    }
    if (Max - Min > k) {
      puts("NO");
      continue;
    }
    puts("YES");
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < Min; j++) ans[i].push_back(1);
      for (int j = 1; j <= a[i] - Min; j++) ans[i].push_back(j);
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < ans[i].size(); j++) {
        cout << ans[i][j];
        if (j != ans[i].size() - 1) cout << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
