#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=a;i<=b;i++)
int a[102], c1[102], c2[102];
int main() {
int n, k;
scanf("%d %d",&n, &k);
FOR(i, 0, n-1) scanf("%d",&a[i]);
vector < vector < int > > v(n);
FOR(i, 0, n-1) v[i].resize(a[i]);
FOR(i, 0, n-1) {
FOR(j, 0, a[i]-1) {
v[i][j] = j%k;
v[i][j]++;
}
}
bool f = true;
FOR(i, 0, n-1) {
FOR(j, i+1, n-1) {
FOR(K, 0, 102) {
c1[K] = 0;
c2[K] = 0;
}
FOR(K, 0, a[i]-1) c1[v[i][K]]++;
FOR(K, 0, a[j]-1) c2[v[j][K]]++;
FOR(K, 0, 102) {
if(abs(c1[K]- c2[K]) > 1) {
f = false;
break;
}
}
if(!f) break;
}
if(!f) break;
}
if(f) {
puts("YES");
FOR(i, 0, v.size()-1) {
FOR(j, 0, v[i].size()-1) printf("%d ",v[i][j]);
puts("");
}
}
else puts("NO");
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSwgYSwgYikgZm9yKGludCBpPWE7aTw9YjtpKyspCmludCBhWzEwMl0sIGMxWzEwMl0sIGMyWzEwMl07CmludCBtYWluKCkgewogICAgaW50IG4sIGs7CiAgICBzY2FuZigiJWQgJWQiLCZuLCAmayk7CiAgICBGT1IoaSwgMCwgbi0xKSBzY2FuZigiJWQiLCZhW2ldKTsKICAgIHZlY3RvciA8IHZlY3RvciA8IGludCA+ID4gdihuKTsKICAgIEZPUihpLCAwLCBuLTEpIHZbaV0ucmVzaXplKGFbaV0pOwogICAgRk9SKGksIDAsIG4tMSkgewogICAgICAgIEZPUihqLCAwLCBhW2ldLTEpIHsKICAgICAgICAgICAgdltpXVtqXSA9IGolazsKICAgICAgICAgICAgdltpXVtqXSsrOwogICAgICAgIH0KICAgIH0KICAgIGJvb2wgZiA9IHRydWU7CiAgICBGT1IoaSwgMCwgbi0xKSB7CiAgICAgICAgRk9SKGosIGkrMSwgbi0xKSB7CiAgICAgICAgICAgIEZPUihLLCAwLCAxMDIpIHsKICAgICAgICAgICAgICAgIGMxW0tdID0gMDsKICAgICAgICAgICAgICAgIGMyW0tdID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgICBGT1IoSywgMCwgYVtpXS0xKSBjMVt2W2ldW0tdXSsrOwogICAgICAgICAgICBGT1IoSywgMCwgYVtqXS0xKSBjMlt2W2pdW0tdXSsrOwogICAgICAgICAgICBGT1IoSywgMCwgMTAyKSB7CiAgICAgICAgICAgICAgICBpZihhYnMoYzFbS10tIGMyW0tdKSA+IDEpIHsKICAgICAgICAgICAgICAgICAgICBmID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoIWYpIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZighZikgYnJlYWs7CiAgICB9CiAgICBpZihmKSB7CiAgICAgICAgcHV0cygiWUVTIik7CiAgICAgICAgRk9SKGksIDAsIHYuc2l6ZSgpLTEpIHsKICAgICAgICAgICAgRk9SKGosIDAsIHZbaV0uc2l6ZSgpLTEpIHByaW50ZigiJWQgIix2W2ldW2pdKTsKICAgICAgICAgICAgcHV0cygiIik7CiAgICAgICAgfQogICAgfQogICAgZWxzZSBwdXRzKCJOTyIpOwogICAgcmV0dXJuIDA7Cn0=