#K4756. Palindrome Rearrangement

    ID: 28225 Type: Default 1000ms 256MiB

Palindrome Rearrangement

Palindrome Rearrangement

You are given an array of n integers. Your task is to determine whether it is possible to rearrange the array into a palindrome.

A palindrome is a sequence that reads the same from left to right as it does from right to left. A valid palindrome rearrangement exists if and only if at most one element has an odd frequency count.

If a valid palindrome exists, output YES on the first line, followed by one valid palindrome permutation (space-separated) on the second line. Otherwise, output NO.

inputFormat

Input is given from standard input.

The first line contains a single integer n (1 ≤ n ≤ 105), representing the number of elements in the array.

The second line contains n space-separated integers. Each integer is in the range [-109, 109].

outputFormat

Output to standard output.

If a palindrome can be formed, print YES on the first line followed by a valid palindrome permutation (space-separated) on the second line.

If no valid palindrome permutation exists, print NO.

## sample
5
1 2 3 2 1
YES

1 2 3 2 1

</p>