n = int(input()) s, t = map(int, input().split()) s, t = s-1, t-1 a = list(map(int, input().split())) cum = [0] for x in a: cum.append(cum[-1] + x) S = cum[-1] ans = -10**20 for l in range(n): r = l + (n-1)//2 #print(l, r) if not (l <= s <= r or s <= r%n <= l): continue if (l <= t <= r or t <= r%n <= l): continue #print(l, r) if r < n: ans = max(ans, 2 * cum[r+1] - 2 * cum[l] - S) else: r %= n ans = max(ans, S - 2 * cum[l] + 2 * cum[r+1]) print(ans)