#K68777. Majority Element Finder
Majority Element Finder
Majority Element Finder
You are given an array of n integers. Your task is to determine the majority element in the array. An element is considered the majority if it appears more than \(\lfloor n/2 \rfloor\) times. If no such element exists, output -1.
Note: The majority condition is strict; the count must be greater than \(\lfloor n/2 \rfloor\) (i.e., more than half of the total number of elements).
For example, in the array [1, 2, 3, 1, 1, 1, 2], the element 1 appears 4 times and since \(4 > \lfloor7/2\rfloor = 3\), 1 is the majority element.
inputFormat
The input is given from standard input (stdin). The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.
outputFormat
Output a single integer which is the majority element if it exists. Otherwise, output -1.
## sample7
1 2 3 1 1 1 2
1