import sys def main(): import sys input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 A = list(map(int, input[idx:idx+N])) idx += N B = list(map(int, input[idx:idx+N])) idx += N min_max = float('inf') for s in range(N): # Generate the order of B starting at s order = [] for i in range(N): order.append(B[(s + i) % N]) current_level = A.copy() count = [0] * N for b in order: # Find the monster with minimal current level, and smallest index if tie min_level = float('inf') selected = -1 for i in range(N): if current_level[i] < min_level: min_level = current_level[i] selected = i elif current_level[i] == min_level: if i < selected: selected = i # Update the selected monster exp = b // 2 current_level[selected] += exp count[selected] += 1 # Compute the maximum count current_max = max(count) if current_max < min_max: min_max = current_max print(min_max) if __name__ == '__main__': main()