import sys from itertools import combinations lines = [line.rstrip('\n').strip() for line in sys.stdin] # Check for the error format (N followed by N numbers in one line) if len(lines) == 2: n_str = lines[0] second_line = lines[1] try: n = int(n_str) parts = second_line.split() if len(parts) == n: print("assert") sys.exit() except: pass # Not the error format, proceed to process # Process the correct format try: n = int(lines[0]) nums = [] for line in lines[1:1 + n]: # Read next n lines, ignoring extra lines parts = line.split() if not parts: num = 0 # Handle empty lines as 0, though input is assumed correct else: num = int(parts[0]) nums.append(num) # Generate all possible sums of two distinct elements sum_set = set() for a, b in combinations(nums, 2): sum_set.add(a + b) # Sort in descending order and find the second largest sorted_sums = sorted(sum_set, reverse=True) if len(sorted_sums) >= 2: print(sorted_sums[1]) else: print(sorted_sums[0] if sorted_sums else 0) except: print("assert")