#include <bits/stdc++.h>
using namespace std;
int p[101], n, k, mn = 101, mx = 0;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    mn = min(mn, p[i]);
    mx = max(mx, p[i]);
  }
  if (mx - mn > k) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < p[i]; j++) {
        if (j) {
          printf(" ");
        }
        printf("%d", j % k + 1);
      }
      printf("\n");
    }
  }
  return 0;
}
