279. Bipermutations

Time limit per test: 2 seconds
Memory limit: 64 megabytes
input: standard
output: standard


A of order is a linear order of objects satisfying the following conditions:

  • For each such that holds
  • For each and such that holds .

    Let

    ( is undefined). Let be the number of such that . You are given integers . You have to find any bipermutation such that for all .

    Input
    The first line of the input contains single integer (). The next line contains the numbers .

    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 ).

    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
    Online Contester Team © 2002 - 2004. All rights reserved.