#include <bits/stdc++.h>
using namespace std;
const int N = 1e9 + 7;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  int maxi = *max_element(v.begin(), v.end());
  int mini = *min_element(v.begin(), v.end());
  if (k < (maxi - mini)) {
    cout << "NO";
    return;
  }
  cout << "YES";
  cout << endl;
  ;
  for (int i = 0; i < n; i++) {
    int temp = 1;
    while (v[i]--) {
      cout << temp;
      temp = temp < k ? temp + 1 : 1;
      cout << " ";
      ;
    }
    cout << endl;
    ;
  }
}
int main() {
  long long int t;
  t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
