eolymp
bolt
Try our new interface for solving problems
Problems

Majority Element

Majority Element

Given an array of size $n$, find the majority element. The majority element is the element that appears more than $⌊n / 2⌋$ times. \InputFile The first line contains number $n~(1 \le n \le 100)$. The second line contains $n$ positive integers. \OutputFile If the array contains majority element, then print it. Otherwise print $-1$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
7
3 3 5 4 2 3 3
Output example #1
3
Input example #2
4
2 3 2 3
Output example #2
-1