n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) # Precompute the enemy order for each starting point order = [B[i:] + B[:i] for i in range(n)] min_max = float('inf') for start in range(n): current_A = A.copy() used = [False] * n count = [0] * n enemies = order[start] for b in enemies: current_min = min(current_A) # Collect all candidates with current_min candidates = [] unused = [] for j in range(n): if current_A[j] == current_min: candidates.append(j) if not used[j]: unused.append(j) # Determine the selected monster if unused: selected = min(unused) else: selected = min(candidates) # Update count and used count[selected] += 1 used[selected] = True current_A[selected] += b // 2 current_max = max(count) if current_max < min_max: min_max = current_max print(min_max)