#include <bits/stdc++.h>
using namespace std;
typedef struct node* nd;
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  ;
  int min = INT_MAX;
  int max = INT_MIN;
  int a[n];
  vector<int> v[1000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < min) {
      min = a[i];
    }
    if (a[i] > max) {
      max = a[i];
    }
  }
  if (max - min > k) {
    cout << "NO";
    cout << "\n";
  } else {
    for (int i = 0; i < min; i++) {
      for (int j = 0; j < n; j++) {
        v[j].push_back(1);
      }
    }
    for (int i = 1; i <= k; i++) {
      for (int j = 0; j < n; j++) {
        if (v[j].size() != a[j]) {
          v[j].push_back(i);
        }
      }
    }
    cout << "YES";
    cout << "\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < v[i].size(); j++) {
        cout << v[i][j] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
