405951: GYM102191 B Final Problem

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Final Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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?

Input

The 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.

Output

Output 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.

ExampleInput
4
3 7 5 5
4 6 5 7 4 4 9 10 7 9
Output
3

加入题单

上一题 下一题 算法标签: