Fermat's Fakini
InterviewTime limit1sMemory limit2048 MB
Given N nicknames split into even and odd gangs, Mirko joins the larger gang and picks the smallest unused natural number with that parity.
- Level
Easy2 of 10
- Topics
- Implementation, Hash map
- Solved
- No attempts yet
Problem
For centuries, PavlovFermat Street has been ruled by two gangs, even-shirts and odd-shirts1. The names are no accident. Every boy in the even-shirts has a nickname that is an even natural number, and every boy in the odd-shirts has a nickname that is an odd natural number. Every boy who lives on Fermat Street belongs to one of the two gangs.
Mirko moved to Fermat Street today and must choose a gang to join. He decided it is better to join the bigger gang. For his nickname, he will pick the smallest natural number that is not yet taken, that is, the smallest natural number such that no boy in the gang he joins has that nickname. Print the nickname Mirko picks.
1 After the contest, be sure to read the novel Junaci Pavlove ulice by Ferenc Molnar.
Input
The first line contains a natural number (), the number of boys (not counting Mirko) who live on Fermat Street. You may assume the two gangs do not have the same number of members.
The second line contains natural numbers less than , where the -th number is the nickname of the -th boy.
Output
Print Mirko's nickname on a single line.
Hint
Explanation of the third sample: there are two even-shirts and three odd-shirts, so Mirko becomes an odd-shirt. His nickname is , the smallest odd natural number, and nobody has that nickname.