def solve_case(): # Read input for this case n = int(input()) a = list(map(int, input().split())) la, ra, lb, rb = map(int, input().split()) # Initialize variables to keep track of which stacks have been claimed claimed = [False] * n # Alice's turn max_a = 0 for i in range(la - 1, ra): if not claimed[i]: max_a = max(max_a, a[i]) claimed[la - 1 + a[la - 1:ra].index(max_a)] = True # Bob's turn max_b = 0 for i in range(lb - 1, rb): if not claimed[i]: max_b = max(max_b, a[i]) claimed[lb - 1 + a[lb - 1:rb].index(max_b)] = True # Alice's and Bob's subsequent turns while True: # Alice's turn next_a = None for i in range(n): if not claimed[i]: if (i > 0 and claimed[i - 1]) or (i < n - 1 and claimed[i + 1]): if next_a is None or a[i] > a[next_a]: next_a = i if next_a is None: break max_a += a[next_a] claimed[next_a] = True # Bob's turn next_b = None for i in range(n): if not claimed[i]: if (i > 0 and claimed[i - 1]) or (i < n - 1 and claimed[i + 1]): if next_b is None or a[i] > a[next_b]: next_b = i if next_b is None: break max_b += a[next_b] claimed[next_b] = True # Output result for this case print(f"Case #{case_num}: {max_a}")