#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > A;
map<pair<int, int>, vector<int> > M;
int main() {
  int n, c;
  scanf("%d", &n);
  scanf("%d", &c);
  for (int i = (0); i < (n); ++i) {
    int a;
    scanf("%d", &a);
    A.push_back(pair<int, int>(a, i));
  }
  sort(A.begin(), A.end());
  int flag = 0;
  for (int i = (0); i < (c); ++i) {
    if (flag == 1) {
      for (int j = (1); j < (n); ++j) {
        if (M[A[j]].size() != A[j].first) {
          M[A[j]].push_back(i);
        }
      }
    } else {
      for (int j = (0); j < (n); ++j) {
        for (int k = (0); k < (A[0].first); ++k) {
          M[A[j]].push_back(i);
        }
        if (A[j].first > A[0].first) {
          M[A[j]].push_back(i);
        }
      }
      flag = 1;
    }
  }
  if (M[A[n - 1]].size() != A[n - 1].first) {
    cout << "NO" << endl;
    return 0;
  } else {
    cout << "YES" << endl;
    vector<int> ans[n];
    for (int i = (0); i < (n); ++i) {
      ans[A[i].second] = M[A[i]];
    }
    for (int i = (0); i < (n); ++i) {
      for (int j = (0); j < (ans[i].size()); ++j) {
        cout << ans[i][j] + 1 << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
