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