n = int(input()) s, t = map(int, input().split()) a = list(map(int, input().split())) def xy(u, v): vis = [False] * n i, j = s - 1, t - 1 x, y = a[i], a[j] vis[i] = True vis[j] = True for k in range(n): if k % 2 == 0: if vis[(i + u) % n]: continue i = (i + u) % n vis[i] = True x += a[i] else: if vis[(j + v) % n]: continue j = (j + v) % n vis[j] = True y += a[j] return x - y print(max(min(xy(-1, -1), xy(-1, 1)), min(xy(1, -1), xy(1, 1))))