#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  int maxi = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    maxi = max(maxi, arr[i]);
  }
  int a = maxi - k;
  a = (a <= 0 ? 0 : a);
  int flag = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] < a) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << "NO"
         << "\n";
  } else {
    cout << "YES"
         << "\n";
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < a; ++j) {
        cout << 1 << " ";
      }
      int b = 1;
      for (int j = a; j < arr[i]; ++j) {
        cout << b << " ";
        ++b;
      }
      cout << "\n";
    }
  }
}
