N = int(input()) assert 4 <= N <= 10 ** 5 s, t = map(int, input().split()) assert 1 <= s <= N assert 1 <= t <= N assert s != t s, t = s-1, t-1 A = [int(a) for a in input().split()] for a in A: assert 1 <= a <= 10 ** 9 su = sum(A) if s < t: X = A[s+1:t] Y = (A[t+1:] + A[:s])[::-1] else: X = A[t+1:s][::-1] Y = A[s+1:] + A[:t] x, y = len(X), len(Y) if x % 2 == y % 2 == 0: ans = (sum(X[:x//2] + Y[:y//2]) + A[s]) * 2 - su elif x % 2 == y % 2 == 1: ans = (max(sum(X[:x//2+1] + Y[:y//2]), sum(X[:x//2] + Y[:y//2+1])) + A[s]) * 2 - su else: ans = (sum(X[:(x+1)//2] + Y[:(y+1)//2]) + A[s]) * 2 - su print(ans)