#C2416. Dominant Element
Dominant Element
Dominant Element
You are given an array of integers. The task is to determine the dominant element in the array, i.e. the element that appears more than \( \lfloor \frac{n}{2} \rfloor \) times (where \( n \) is the size of the array). If such an element exists, output it; otherwise, output \(-1\).
The input is given as follows:
- The first line contains an integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers.
The output should consist of a single line with the dominant element or \(-1\) if no dominant element exists.
inputFormat
The first line of input contains a single integer \( n \) (the number of elements in the array). The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Output a single integer which is the dominant element if it exists (an element that appears more than \( \lfloor \frac{n}{2} \rfloor \) times), otherwise output \(-1\).
## sample5
3 3 4 2 3
3
</p>