Kryzhanivskyi's Lot
Petryk is playing a game with his friends called "Kryzhanivsky's Draw." The rules are simple: in each round, every player selects a random natural number. The player who picks the smallest number that no one else has chosen wins that round, and their score for that round is the number they selected. For instance, if there are 6 players and the numbers chosen are 3, 2, 1, 1, 4, and 2, the first player wins with a score of 3. If all numbers are repeated, the round is a draw, and no points are awarded.
The total score for a player is the sum of their points from all rounds played.
Petryk and his friends take turns announcing their chosen numbers, then determine the winner and tally the points. However, players can "cheat" by not selecting a number in advance. Instead, they can wait to hear the numbers chosen by others and then pick an optimal number. Petryk uses this strategy by naming his number last, aiming to maximize his score.
It's the final round of the game. The scores of all players before this round and the numbers chosen by the players are known. Your task is to determine which number Petryk should choose so that the number of players with fewer points than him is maximized. If there are multiple such numbers, Petryk wants to choose the smallest one.
Input
The first line contains the number n – the number of players (2 ≤ n ≤ 100). The second line contains n numbers – the players' scores before the last round (non-negative numbers, not exceeding 100). The scores are listed in the order in which the players usually announce their numbers (i.e., Petryk's score is listed last). The third line contains (n–1) numbers – the numbers chosen by the players in the last round (numbers do not exceed 100), in the order they were chosen.
Output
Output the number Petryk should choose.