import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; public class Main { public static class Status implements Comparable { int level, count; public Status(int level, int count) { super(); this.level = level; this.count = count; } @Override public int compareTo(Status o) { if(Integer.compare(this.level, o.level) != 0){ return Integer.compare(this.level, o.level); }else{ return Integer.compare(this.count, o.count); } } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); int[] As = new int[N]; int[] Bs = new int[N]; for(int i = 0; i < N; i++){ As[i] = sc.nextInt(); } for(int i = 0; i < N; i++){ Bs[i] = sc.nextInt(); } int answer = Integer.MAX_VALUE; for(int B_start = 0; B_start < N; B_start++){ PriorityQueue queue = new PriorityQueue(); for(int i = 0; i < N; i++){ queue.add(new Status(As[i], 0)); } for(int i = 0; i < N; i++){ final int B_battle = (B_start + i) % N; final Status A_battle = queue.poll(); //System.out.println(B_start + " " + A_battle.level + " " + A_battle.count); A_battle.count++; A_battle.level += Bs[B_battle] / 2; queue.add(A_battle); } int max = Integer.MIN_VALUE; while(!queue.isEmpty()){ max = Math.max(max, queue.poll().count); } answer = Math.min(answer, max); } System.out.println(answer); } }