import java.util.*; import java.awt.geom.*; import java.io.*; class Main { static int[] vx = {1,0,-1,0}; static int[] vy = {0,1,0,-1}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); } for(int i = 0; i < n; i++) { b[i] = sc.nextInt()/2; } int min = 2 << 29; for(int i = 0; i < n; i++) { PriorityQueue p = new PriorityQueue(); for(int j = 0; j < n; j++) { p.add(new Data(a[j],0)); } int max = 0; for(int j = 0; j < n; j++) { Data tmp = p.poll(); tmp.b++; tmp.a += b[(j + i) % n]; p.add(tmp); max = Math.max(max, tmp.b); } min = Math.min(min,max); } System.out.println(min); } static class Data implements Comparable{ int a; int b; Data(int c, int d) { a = c; b = d; } @Override public int compareTo(Data o) { if(o.a == this.a) return this.b - o.b; return this.a - o.a; } } }