mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) s, t = map(int, input().split()) s -= 1 t -= 1 A = list(map(int, input().split())) DS = [0] * N DT = [0] * N for i in range(N): DS[i] = min(abs(i - s), abs(i - (N+s))) DT[i] = min(abs(i - t), abs(i - (N + t))) ans = 0 tmp = [] for i in range(N): if DS[i] < DT[i]: ans += A[i] elif DS[i] > DT[i]: ans -= A[i] else: tmp.append(A[i]) if len(tmp) == 2: ans += max(tmp) - min(tmp) elif len(tmp) == 1: ans += tmp[0] print(ans) if __name__ == '__main__': main()