#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
template <class T>
T _abs(T n) {
  return (n < 0 ? -n : n);
}
template <class T>
T _max(T a, T b) {
  return (!(a < b) ? a : b);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T _swap(T& a, T& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
template <class T>
T gcd(T a, T b) {
  return (b == 0 ? a : gcd(b, a % b));
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b) * b);
}
int main() {
  int n, k;
  while (cin >> n >> k) {
    int r[n + 1], m = 0, min_;
    for (int i = 0; i < n; i++) {
      cin >> r[i];
      if (r[i] > m) m = r[i];
      if (i == 0)
        min_ = r[i];
      else {
        if (r[i] < min_) {
          min_ = r[i];
        }
      }
    }
    int a[n + 1][m + 1];
    memset(a, 0, sizeof(a));
    map<int, int> mp;
    mp.clear();
    int akhon = 0, flag = 1;
    for (int i = 0; i < n; i++) {
      int c = 1;
      for (int j = 0; j < r[i]; j++) {
        if (j <= min_) {
          a[i][j] = c;
        } else {
          c++;
          a[i][j] = c;
          if (c > k) {
            flag = 0;
            break;
          }
        }
      }
      if (flag == 0) {
        break;
      }
    }
    if (flag) {
      cout << "YES\n";
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < r[i]; j++) {
          if (j != 0) cout << " ";
          cout << a[i][j];
        }
        cout << endl;
      }
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
