import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] homes = new int[n]; for (int i = 0; i < n; i++) { homes[i] = sc.nextInt(); } int[] enemies = new int[n]; for (int i = 0; i < n; i++) { enemies[i] = sc.nextInt(); } int min = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { int max = 0; PriorityQueue queue = new PriorityQueue<>(); for (int j = 0; j < n; j++) { queue.add(new Monster(homes[j])); } for (int j = 0; j < n; j++) { Monster m = queue.poll(); m.count++; max = Math.max(max, m.count); m.value += enemies[(i + j) % n] / 2; queue.add(m); } min = Math.min(min, max); } System.out.println(min); } static class Monster implements Comparable { int count; int value; public Monster(int value) { this.value = value; } public int compareTo(Monster another) { if (value == another.value) { return count - another.count; } else { return value - another.value; } } public String toString() { return "[" + count + ":" + value + "]"; } } }