405951: GYM102191 B Final Problem
Description
You have a problem set of ten problems. Each team in the contest has a skill level from 1 to 10 and each of the ten problems has a difficulty level from 1 to 10. A team can only solve problems that have a difficulty level less than or equal to their skill level.
You want to add one more problem with difficulty from 1 to 10 such that each team solves at least one problem. What is the maximum difficulty that this problem can have?
InputThe first line of input contains n (1 ≤ n ≤ 32), the number of teams participating in the contest.
The second line of input contains n integers si (1 ≤ si ≤ 10), the skill level of the teams.
The third line of input contains 10 integers di (1 ≤ di ≤ 10), the difficulty level of the problems in the problem set so far.
OutputOutput on a single line the maximum possible difficulty level for the new problem from 1 to 10 such that each team solves at least one problem.
ExampleInput4 3 7 5 5 4 6 5 7 4 4 9 10 7 9Output
3