#!/usr/bin/env python3 import sys input = sys.stdin.readline from heapq import heappush, heappop n = int(input()) a = [int(item) for item in input().split()] b = [int(item) for item in input().split()] ans = 10**9 for diff in range(n): hq = [] ret = 0 for item in a: heappush(hq, (item, 0)) for i in range(diff, diff + n): lv, times = heappop(hq) heappush(hq, (lv + b[i % n] // 2, times + 1)) if ret < times + 1: ret = times + 1 ans = min(ans, ret) print(ans)