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 Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
import java.util.*;

public class Main {
	
	static PrintWriter out;
	
	final static int INF = (int) 1e9;
	final static int MOD = (int) 1e9 + 7;
	final static long LINF = (long) 1e18;
	final static double PI = (double) Math.acos(-1.0);
	final static double EPS = (double) 1e-9;
	
	void solve() {
		int n = Input.nextInt();
		final int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Input.nextInt() - 1;
		}
		ArrayList<Integer> v = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			v.add(i);
		}
		Collections.sort(v, new Comparator<Integer>() {
			public int compare(Integer i, Integer j) {
				if (x[i] == x[j]) return Integer.compare(i, j);
				return Integer.compare(x[i], x[j]);
			}
		});
		int[] res = new int[n * n];
		for (int i = 0; i < n; i++) {
			res[x[i]] = i + 1;
		}
		for (int j = 0; j < n; j++) {
			int i = v.get(j);
			int cnt = i;
			for (int k = x[i] - 1; k >= 0 && cnt > 0; k--) {
				if (res[k] == 0) {
					res[k] = i + 1;
					cnt--;
				}
			}
			if (cnt > 0) {
				out.println("No");
				return;
			}
			cnt = n - i - 1;
			for (int k = n * n - 1; k > x[i] && cnt > 0; k--) {
				if (res[k] == 0) {
					res[k] = i + 1;
					cnt--;
				}
			}
			if (cnt > 0) {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
		for (int i = 0; i < n * n; i++) {
			out.printf("%d%c", res[i], " \n".charAt(i == n * n - 1 ? 1 : 0));
		}
	}
	
	public static void main(String[] args) {
		try {
			out = new PrintWriter(System.out);
			//out = new PrintWriter(new FileWriter("a.out"));
		}
		catch (Exception ex) {
		}
		long stime = System.currentTimeMillis();
		Main practice = new Main();
		practice.solve();
		if (System.getProperty("_LOCAL_") != null) {
			out.println("\nTime elapsed: " + (System.currentTimeMillis() - stime) + "ms");
		}
		out.close();
	}
	
	static class Input {
		static StringTokenizer token = null;
		static BufferedReader in;
		static {
			try {
				if (System.getProperty("ONLINE_JUDGE") != null) {
					//in = new BufferedReader(new FileReader("in.txt"));
					in = new BufferedReader(new InputStreamReader(System.in));
				}
				else {
					in = new BufferedReader(new InputStreamReader(System.in));
				}
			}
			catch (Exception ex) {
			}
		}
		static int nextInt() {
			return Integer.parseInt(nextString());
		}
		static long nextLong() {
			return Long.parseLong(nextString());
		}
		static double nextDouble() {
			return Double.parseDouble(nextString());
		}
		static String nextString() {
			try {
				while (token == null || !token.hasMoreTokens()) {
					token = new StringTokenizer(in.readLine());
				}
			}
			catch (IOException e) {
			}
			return token.nextToken();
		}
	}
}