#include <iostream>
#include <limits.h>
#include <algorithm>
using namespace std;
const int N = 2e5 + 10;
int n, m;
int nums1[N], nums2[N];
int median(int nums1[], int i, int nums2[], int j, int k)
{
if (i == n) return nums2[j + k - 1]; //起始位置大于数组长度,则返回另一个数组的第k个数
if (j == m) return nums1[i + k - 1];
if (k == 1) return min(nums1[i], nums2[j]);
int median1 = (i + k / 2 - 1) < n ? nums1[i + k / 2 - 1] : INT_MAX;
int median2 = (j + k / 2 - 1) < m ? nums2[j + k / 2 - 1] : INT_MAX;
if (median1 < median2) return median(nums1, i + k / 2, nums2, j, k - k / 2);
else return median(nums1, i, nums2, j + k / 2, k - k / 2);
}
int main()
{
cin >> n;
for (int i = 0; i < n; i ++ ) cin >> nums1[i];
cin >> m;
for (int i = 0; i < n; i ++ ) cin >> nums2[i];
int mid = (n + m + 1) >> 1;
cout << median(nums1, 0, nums2, 0, mid) << endl;
return 0;
}