import java.io.*;
import java.util.*;

public class game_md implements Runnable {
	private Scanner in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private void solve() throws IOException {
		Locale.setDefault(Locale.US);
		in = new Scanner(new FileReader("game.in"));
		out = new PrintWriter("game.out");
		int n = in.nextInt();
		int[] score = new int[n];
		for (int i = 0; i < n; i++) {
			score[i] = in.nextInt();
		}
		int[] a = new int[n];
		for (int i = 0; i < n - 1; i++) {
			a[i] = in.nextInt();
		}
		int[] amount = new int[102];
		int[] s = new int[n];
		int best = -1;
		int ans = 0;
		for (a[n - 1] = 1; a[n - 1] <= 101; a[n - 1]++) {
			Arrays.fill(amount, 0);
			for (int i = 0; i < n; i++) {
				amount[a[i]]++;
			}
			int winNumber = 0;
			for (int i = 1; i <= 101; i++) {
				if (amount[i] == 1) {
					winNumber = i;
					break;
				}
			}
			System.arraycopy(score, 0, s, 0, n);
			for (int i = 0; i < n; i++) {
				if (a[i] == winNumber) {
					s[i] += winNumber;
					break;
				}
			}
			int cur = 0;
			for (int i = 0; i < n - 1; i++) {
				if (s[i] < s[n - 1]) {
					cur++;
				}
			}
			if (cur > best) {
				best = cur;
				ans = a[n - 1];
			}
		}
		out.println(ans);
		in.close();
		out.close();
	}

	public static void main(String[] args) {
		new Thread(new game_md()).start();
	}
}
