from heapq import heapify, heappop, heappush N = int(input()) T = [int(s) for s in input().split()] S = [int(s) for s in input().split()] pq = [(s, i) for i, s in enumerate(S)] heapify(pq) ans = 0 is_proceed = False while pq: time, idx = heappop(pq) if idx == -1: is_proceed = False continue if not is_proceed: is_proceed = True heappush(pq, (time + T[idx], -1)) ans += 1 print(ans)