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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC008
{
    public class D
    {
        private const string Yes = "Yes";
        private const string No = "No";
        private void Run()
        {
            var N = int.Parse(Console.ReadLine().Trim());
            var X = Console.ReadLine().Trim().Split().Select(int.Parse)
                .Select(x => x - 1) // to 0-indexed
                .ToArray();

            if (X.Distinct().Count() != X.Length) { goto No; }

            var array = Enumerable.Range(0, N)
                .Select(i => Tuple.Create(X[i], i + 1)) // [index, value]
                .OrderBy(t => t.Item1)
                .ToArray();

            var head = new Queue<int>();
            var rest = new Queue<int>();
            var resArray = new int[N * N];

            foreach (var t in array)
            {
                for (int i = 0; i < t.Item2 - 1; i++)
                {
                    head.Enqueue(t.Item2);
                }
            }

            var used = new bool[N];
            int index = 0;
            for (int i = 0; i < resArray.Length; i++)
            {
                int currentValue;
                if (index < array.Length && i == array[index].Item1)
                {
                    int arrayValue = array[index].Item2;
                    currentValue = arrayValue;
                    for (int j = arrayValue + 1; j <= N; j++)
                    {
                        rest.Enqueue(arrayValue);
                    }
                    used[arrayValue - 1] = true;
                    index++;
                }
                else
                {
                    if (head.Count > 0)
                    {
                        currentValue = head.Dequeue();
                        if (used[currentValue - 1]) { goto No; }
                    }
                    else
                    {
                        if (rest.Count == 0) { goto No; }
                        currentValue = rest.Dequeue();
                    }
                }
                resArray[i] = currentValue;
            }

            Console.WriteLine(Yes);
            Console.WriteLine(string.Join(" ", resArray));
            return;

            No:
            Console.WriteLine(No);
            return;
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new D().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}