import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); String[] A = br.readLine().split(" "); String[] B = br.readLine().split(" "); PriorityQueue pq = new PriorityQueue(); for (int i = 0; i < N; i++) { int[] a = new int[]{Integer.parseInt(A[i]), 0}; CustomComparator aa = new CustomComparator(a); pq.add(aa); } int maxMini = Integer.MAX_VALUE; for (int i = 0; i < N; i++) { int tmpMax = 0; for (int j = 0; j < N; j++) { int enemy = i + j; if (enemy >= N) { enemy = enemy - N; } CustomComparator tmp = pq.poll(); tmp.a[0] = tmp.a[0] + (Integer.parseInt(B[enemy]) / 2); tmp.a[1] = tmp.a[1] + 1; if (tmpMax < tmp.a[1]) { tmpMax = tmp.a[1]; } pq.add(tmp); } if (maxMini > tmpMax) { maxMini = tmpMax; } } System.out.println(maxMini); } static class CustomComparator implements Comparable { int[] a; public CustomComparator(int[] a) { this.a = a; } //比較メソッド(データクラスを比較して-1, 0, 1を返すように記述する) public int compareTo(CustomComparator b) { int no1 = a[0]; int no2 = b.a[0]; int no3 = a[1]; int no4 = b.a[1]; //こうすると社員番号の昇順でソートされる if (no1 > no2) { return 1; } else if (no1 == no2) { if (no3 > no4) { return 1; } else if (no3 == no4) { return 0; } else { return -1; } } else { return -1; } } } }