279. Bipermutations

Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard



Aof order n is a linear order of 2n objects satisfying the following conditions:

  • For each i such that 1≤ in holds
  • For each i and j such that 1≤ i,jn holds .

    Let

    (bii is undefined). Let a(i) be the number of such j that . You are given integers a1,a2,..., an. You have to find any bipermutation such that a(i)=ai for all i.

    Input
    The first line of the input contains single integer n (1≤ n≤ 1000). The next line contains the numbers a1,...,an.

    Output
    If there is no solution, the only line of the output must contain single word 'NO' (without quotes). Otherwise the first line of the output must contain single word 'YES' (without quotes); the rest of the output must contain the objects ordered with respect to the bipermutation ( is output as -i).

    Example(s)
    sample input
    sample output
    9
    2 0 3 0 4 8 1 5 4
    
    YES
    -6 -8 -9 6 -5 -3 8 9 -7 5 -1 -4 3 7 -2 1 4 2 
    



    Hint: If and , then .

    Novosibirsk SU Contest #2, by Novosibirsk Team #1