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: Wrong Answer)

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
typedef pair<LL, LL> Pll;
typedef pair<LL, LL> Vec2;
LL h, w, n, m, s, t, ans = 0, a[10000000], b[10000000], num = 1, sum = 0, dp[3200][3200] = {};

int main() {
	cin >> n;
	vector<char> str(n*n+1);
	for (int i = 0; i < str.size(); i++)
		str[i] = 99999;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		
		b[a[i]] = 1;
		str[a[i]] = i+'0';
	}
	sum = n*n;
	for (int i = n - 1; i >= 1; i--) {
		int num = 0;
		for (int j = sum; j >= 0; j--) {
			if (str[j] >= '1' && str[j] <= '9') {}
			else if(j>a[i]){
				str[j] = i+'0';
				num++;
			}
			if (num == n - i) {
				sum = j;
				break;
			}
			if(j==0){
				cout << "No" << endl;
				return 0;
			}

		}
	}
	t = 3; sum = 0;
	for (int i = 1; i <= n*n; i++) {
		if (str[i] >= '1' && str[i] <= '9') {}
		else {
			str[i] = t + '0';
			sum++;
		}
		if (sum == t - 1) {
			t--;
			sum = 0;
			if (t == 1)break;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n*n; i++) {
		cout << str[i];
		if (i != n*n)
			cout << " ";
	}
	cout << endl;
	return 0;
}