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.
Example
Input
4
3 7 5 5
4 6 5 7 4 4 9 10 7 9
Output
3
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int maxn = 2e5 + 5;
int a[maxn];
int main()
{
int n;
scanf("%d",&n);
int minn = inf;
for(int i = 1; i <= n; i++)
{
scanf("%d",&a[i]);
minn = min (minn, a[i]);
}
int minn1 = inf;
int tmp;
for(int i = 1; i <= 10; i++)
{
scanf("%d",&tmp);
minn1 = min (minn1 , tmp);
}
if(minn < minn1)
{
printf("%d\n",minn);
}
else
{
printf("%d\n", 10);
}
return 0;
}