#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, t, ans, res, sum, mn = 1e9, cnt, mx, k, z, mnn = 1e9, mxx,
                                  b = 1, i;
string s1, s3, s2, s;
set<int> st;
pair<int, int> p[1000001];
vector<int> v, v1, v3, v4, v2;
map<char, int> mp, mpp;
char c, d, e, a;
bool tr = false, fl = false;
int used[10001];
int main() {
  cin >> n >> m;
  x = 1;
  for (int i = 0; i < n; i++) cin >> y, v.push_back(y), mx = max(mx, y);
  for (int i = 0; i < v.size(); i++) mn = min(mn, v[i]);
  sum = mn + m;
  if (mx > sum)
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (int i = 0; i < v.size(); i++) {
      x = 1;
      for (int j = 0; j < v[i]; j++) {
        cout << x << " ";
        x++;
        if (x > m) x = 1;
      }
      cout << endl;
    }
  }
}
