import java.util.*; public class Yuki009 { static class Tuple implements Comparable { int level; int count; Tuple(int level, int count) { this.level = level; this.count = count; } @Override public int compareTo(Tuple o) { int value = Integer.compare(level, o.level); if (value == 0) { return Integer.compare(count, o.count); } return value; } } static int N = 1500; static int K = 10000; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); N = scanner.nextInt(); int[] party = new int[N]; int[] enemy = new int[N]; long exec_time = new Date().getTime(); for (int i = 0; i < N; i++) { party[i] = scanner.nextInt(); } for (int i = 0; i < N; i++) { enemy[i] = scanner.nextInt(); } int min = N; for (int i = 0; i < N; i++) { PriorityQueue queue = new PriorityQueue(N); for (int k = 0; k < N; k++) { queue.add(new Tuple(party[k], 0)); } for (int j = 0; j < N; j++) { Tuple t = queue.poll(); t.level += enemy[(i + j) % N] / 2; t.count++; queue.add(t); } //最後に一番試合数が要素を見つけるので配列に起こす。 Tuple[] tuples = queue.toArray(new Tuple[0]); int max = 0; for (Tuple t : tuples) { max = Math.max(max, t.count); } min = Math.min(min, max); } System.out.println(min); System.err.println(new Date().getTime() - exec_time + "ms"); } }