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: Accepted)

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

typedef pair<int, int> p_ii;

int main() {
  int N; cin >> N;
  p_ii pos[N]; rep(i,N) { int x; cin >> x; pos[i] = make_pair(i,x-1); }

  queue<int> part;
  sort(pos,pos+N,[](const p_ii &x, const p_ii &y){ return x.second<y.second; });
  for (auto x: pos) rep(i,x.first) part.push(x.first);
  // reverse(pos,pos+N);
  for (auto x: pos) rep(i,(N-1)-x.first) part.push(x.first);
  // while(!part.empty()) { cout << part.front() << " "; part.pop(); } cout << endl;

  // reverse(pos,pos+N);
  // rep(i,N) cout << pos[i].first << "->" << pos[i].second << endl;
  int ipos = 0;
  int result[N*N];
  int count[N] = {};
  rep(i,pow(N,2)) {
    if (pos[ipos].second==i) {
      if (pos[ipos].first==count[pos[ipos].first]) {
        result[i] = pos[ipos].first+1;
        count[pos[ipos].first]++;
        ipos++;
      }
      else {
        cout << "No" << endl;
        return 0;
      }
    }
    else {
      result[i] = part.front()+1;
      count[part.front()]++;
      part.pop();
    }
  }
  cout << "Yes" << endl;
  rep(i,pow(N,2)) cout << result[i] << " "; cout << endl;
  return 0;
}