#C854. Dominant Element

    ID: 52533 Type: Default 1000ms 256MiB

Dominant Element

Dominant Element

You are given several sequences of integers. For each sequence, you are required to find the dominant element, if it exists. An element is considered dominant if it appears more than \(\frac{N}{2}\) times in the sequence, where \(N\) is the number of elements in that sequence. If no such dominant element exists, output \(-1\).

Example:

Input:
1
5
1 2 3 3 3

Output: 3

</p>

In the above example, the number 3 appears 3 times and 3 > \(\frac{5}{2}\), so the dominant element is 3.

inputFormat

The input begins with an integer \(T\), the number of test cases. For each test case, the first line contains an integer \(N\) indicating the number of elements. The following line contains \(N\) space-separated integers representing the sequence.

outputFormat

For each test case, output the dominant element on a separate line. If no dominant element exists, output \(-1\).

## sample
1
5
1 2 3 3 3
3