402374: GYM100739 H Hard Molecules

Memory Limit:256 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Hard Moleculestime limit per test0.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

The mad scientist Dexter performs experiments in molecular chemistry. Today he will try to build a single molecule out of n atoms.

It is well-known that a molecule consists of individual atoms, some pairs of which are connected by atomic bonds. Each atom has its value of valence — the number of the bonds the atom can form with other atoms. An atom can form one or several bonds with another atom, but not with itself. The number of the bonds the atom has must be equal to its valency. A molecule must be connected, i.e. for each pair of atoms there must be a path of the bonds that connects the two atoms.

Dexter knows the valences of each of the n atoms. Help him find a molecule that can be built out of these atoms, or determine that it is impossible.

Input

The first line of input contains a single integer n (1 ≤ n ≤ 5000), the number of atoms. The second line contains n space-separated integers di (1 ≤ di ≤ 109), where di is equal to the valence of the i-th atom.

Output

If it is possible to build a single connected molecule out of the given atoms, in the first line output "Yes". Then output n - 1 lines, where i-th line must contain n - i space-separated integer numbers. The j-th number in the i-th line must denote the number of the bonds between the atoms with numbers i and i + j. The atoms are numbered from 1 to n in the order as they appear in the input. If there are several solutions, output any of them.

If such molecule does not exist, output "No" in a single line (without quotes).

ExamplesInput
2
200 200
Output
Yes
200
Input
3
3 5 4
Output
Yes
2 1
3
Input
3
1 1 1
Output
No

加入题单

上一题 下一题 算法标签: