import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") from heapq import heappop, heappush import copy def getlist(): return list(map(int, input().split())) #処理内容 def main(): N = int(input()) A = list(sorted(getlist())) B = getlist() # [レベル、戦闘回数] Q = [] for i in range(N): heappush(Q, [A[i], 0]) ans = INF for i in range(N): start = i Q2 = copy.deepcopy(Q) for j in range(N): lv, cnt = heappop(Q2) lv += int((B[(start + j) % N]) // 2) cnt += 1 heappush(Q2, [lv, cnt]) val = 0 for j in range(N): val = max(val, Q2[j][1]) ans = min(ans, val) print(ans) if __name__ == '__main__': main()