#P11936. Joining the Gang

    ID: 14043 Type: Default 1000ms 256MiB

Joining the Gang

Joining the Gang

There are two gangs: the odd gang and the even gang. Each member has a unique positive integer nickname. Members of the odd gang have odd nicknames, and members of the even gang have even nicknames.

You are given an integer n representing the number of people who have already joined either gang, along with their nicknames. Mirko wants to join one of these gangs. He will choose the gang with a larger number of members. In the event of a tie, choose the odd gang. Then, he will pick the smallest positive integer of that gang's required parity that has not already been used as a nickname. Your task is to determine Mirko's new nickname.

Note: All nicknames are unique.

inputFormat

The first line contains a single integer n representing the number of people who have already joined a gang.

The second line contains n space-separated positive integers representing the nicknames of the gang members.

outputFormat

Output a single integer representing Mirko's new nickname.

sample

4
1 2 3 4
5