Problem:
Score : 800 points

Problem Statement

You are given an integer sequence x of length N.
Determine if there exists an integer sequence a that satisfies all of the following conditions, and if it exists, construct an instance of a.

a is N^2 in length, containing N copies of each of the integers 1, 2, ..., N.

For each 1 ≤ i ≤ N, the i-th occurrence of the integer i from the left in a is the x_i-th element of a from the left.

Constraints

1 ≤ N ≤ 500

1 ≤ x_i ≤ N^2

All x_i are distinct.

Input

The input is given from Standard Input in the following format:

N
x_1 x_2 ... x_N

Output

If there does not exist an integer sequence a that satisfies all the conditions, print No.
If there does exist such an sequence a, print Yes in the first line, then print an instance of a in the second line, with spaces inbetween.

Sample Input 1

3
1 5 9

Sample Output 1

Yes
1 1 1 2 2 2 3 3 3

For example, the second occurrence of the integer 2 from the left in a in the output is the fifth element of a from the left.
Similarly, the condition is satisfied for the integers 1 and 3.

Sample Input 2

2
4 1

Sample Output 2

No

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
int kai_size = 100001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);

vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, kai_size - 1) {
		kai[i + 1] = (kai[i] * (i + 1)) % p;
	}
	rep(i, kai_size) {
		ink[i] = inv(kai[i]);
	}
}
int RE() {
	vel v(3, 2);
	return v.at(4);
}
signed main() {
	int n; cin >> n;
	V<pin> x(n);
	rep(i, n) {
		int a; cin >> a; a--;
		x[i] = mkp(a, i);
	}
	sor(x);
	vvel ans(n);
	vel pq(0);
	rep(i, n) {
		rep(j, x[i].second) {
			pq.push_back(x[i].second);
		}
	}
	rep(i, n) {
		rep(j,n-1- x[i].second) {
			pq.push_back(x[i].second);
		}
	}
	int now_val = 0;
	auto itr = pq.begin();
	rep(i, n) {
		while (now_val < x[i].first) {
			int pla = *itr;
			if (ans[pla].size() == pla) { cout << "No" << endl; return 0; }
			ans[pla].push_back(now_val);
			itr++;
		}
		int pla = x[i].second;
		if (ans[pla].size() < pla) { cout << "No" << endl; return 0; }
		ans[pla].push_back(x[i].first);
	}
	while (now_val < n*n) {
		int pla = *itr;
		if (ans[pla].size() == pla) { cout << "No" << endl; return 0; }
		ans[pla].push_back(now_val);
		itr++;
	}
	vel ret(n*n);
	rep(i, n) {
		rep(j, n) {
			ret[ans[i][j]] = i;
		}
	}
	rep(i, n*n) { cout << ret[i] << endl; }
	return 0;
}