#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
  int A[N + 1];
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  int max = INT_MIN;
  for (int i = 0; i < N; i++)
    if (A[i] > max) max = A[i];
  int min = INT_MAX;
  for (int i = 0; i < N; i++)
    if (A[i] < min) min = A[i];
  if (max - min > K)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < N; i++) {
      if (A[i] <= K) {
        for (int j = 1; j <= A[i]; j++) printf("%d ", j);
        printf("\n");
      } else {
        int count = 0;
        while (count < A[i]) {
          for (int j = 1; j <= K; j++) {
            if (count >= A[i]) break;
            printf("%d ", j);
            count++;
          }
        }
        printf("\n");
      }
    }
  }
  return 0;
}
