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