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# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] x = sc.IntArray();

        var sortedX = new int[n];
        for (int i = 0; i < n; i++)
        {
            sortedX[i] = i;
        }

        Array.Sort(sortedX, (l, r) => sortedX[l].CompareTo(sortedX[r]));

        int[] a = new int[n * n];
        int index = 0;
        foreach (int i in sortedX)
        {
            for (int j = 0; j < i; j++)
            {
                while (a[index] != 0)
                {
                    index++;
                }

                a[index++] = i + 1;
            }

            if (a[x[i] - 1] != 0)
            {
                Console.WriteLine("No");
                return;
            }

            a[x[i] - 1] = i + 1;
        }

        index = n * n - 1;
        for (int t = n - 1; t >= 0; t--)
        {
            int i = sortedX[t] + 1;
            for (int j = 0; j < n - i; j++)
            {
                while (a[index] != 0)
                {
                    if (a[index] == i)
                    {
                        Console.WriteLine("No");
                        return;
                    }

                    index--;
                }

                a[index--] = i;
            }
        }

        Console.WriteLine("Yes");
        Console.WriteLine(string.Join(" ", a));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}