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