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