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# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] X = new int[N];
        for(int i=0;i<N;i++){
            X[i] = int.Parse(str[i]);
        }
        int[] a = new int[N];
        for(int i=0;i<N;i++){
            a[i] = i;
        }
        Array.Sort(a,(x,y) => X[x]-X[y]);
        int[] L = new int[N];
        for(int i=0;i<N;i++){
            L[i] = N;
        }
        int[] Y = new int[N*N];
        bool[] finished = new bool[N*N];
        int p = 0;
        bool b = true;
        for(int i=0;i<N;i++){
            int d = a[i] + 1;
            finished[X[a[i]]-1] = true;
            Y[X[a[i]]-1] = a[i] + 1;
            L[a[i]] -= a[i]+1; 
            for(int j=0;j<a[i];j++){
                while(p < N && finished[p]){
                    p++;
                }
                Y[p] = d;
                p++;
                if(p > X[a[i]] - 1){
                    b = false;
                }
            }
        }
        int q = 0;
        for(;p<N*N;p++){
            if(finished[p]){
                continue;
            }
            while(q < N && L[q] == 0){
                q++;
            }
            if(q == N){
                b = false;
                break;
            }
            else{
                Y[p] = q+1;
                L[q]--;
            }
        }
        if(b){
            sb.Append("Yes\n");
            for(int i=0;i<N*N;i++){
                sb.Append(Y[i]+" ");
            }
            sb.Append("\n");
        }
        else{
            sb.Append("No\n");
        }
    }
}