For Halloween, Mondialu went to each of his neighbors to ask for candies. In order to receive the maximum number of candies, he needs to be as scary as possible.
Mondialu has Halloween costumes . He needs to choose a subsequence (a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements) from the costumes (yes, \t{Mondialu} can wear multiple costumes, this is the level of scariness we are dealing with).
A subsequence is the scariest if it has the following properties:
- Has an even positive length.
- The first half of the subsequence is equal to the second half.
- It is the lexicographically largest subsequence.
An array is lexicographically larger than an array if there exist an so that and or if is a prefix of .
Input data
The first line of each test case contains a single integer , - the length of the array.
The second line of each test case contains integers , - the elements of the array.
Output data
Output a single line, the elements of the scariest subsequence separated by spaces. If no such subsequence exists, print -1
.
Constraints and clarifications
- for points;
- for points;
- for points;
- for points.
Example 1
stdin
8
3 1 2 3 2 3 3 3
stdout
3 3 3 3
Explanation
In the first example, the subsequence has an even positive length () and the first half is equal to the second half . This is the lexicographically largest subsequence which respects the conditions.
Example 2
stdin
3
1 2 3
stdout
-1
Explanation
In the second example, we cannot generate any subsequence which would respect the conditions, so the output is -1
.