#include <bits/stdc++.h>
using namespace std;
int n, arr[101], color, maxi, mini = 101;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> color;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    mini = min(mini, arr[i]);
    maxi = max(maxi, arr[i]);
  }
  if (maxi - mini > color) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    int j = 1;
    while (arr[i]--) {
      cout << j << " ";
      if (j == color) j = 0;
      j++;
    }
    cout << endl;
  }
  return 0;
}
