#C3134. Determine the Election Winner

    ID: 46528 Type: Default 1000ms 256MiB

Determine the Election Winner

Determine the Election Winner

You are given an integer n representing the total number of votes, and a list of n integers representing votes for candidates. Each vote is an integer denoting a candidate. Your task is to determine the candidate who received the highest number of votes.

If two or more candidates obtain the same maximum number of votes, the candidate with the smaller integer value is declared the winner. Formally, if candidates a and b both receive v votes and a > b, then candidate b wins. This condition can be written in \( \LaTeX \) as:

[ \text{If } count(a)=count(b)=v \text{ and } a>b, \text{ then } b \text{ wins.} ]

The input is provided via standard input and the result should be printed on standard output.

inputFormat

The input consists of two lines:

  • The first line contains a single integer n indicating the total number of votes.
  • The second line contains n space-separated integers representing the votes for each candidate.

outputFormat

Output a single integer which is the candidate that wins the election, based on the vote counts and tie-breaking rule explained above.

## sample
10
1 2 2 3 3 3 1 2 3 2
2