import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Collections; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); int s = Integer.parseInt(sa[0]) - 1; int t = Integer.parseInt(sa[1]) - 1; sa = br.readLine().split(" "); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); long x = 0; long y = 0; PriorityQueue que = new PriorityQueue<>(Collections.reverseOrder()); for (int i = 0; i < n; i++) { int ds = Math.min(Math.min(Math.abs(i - s), Math.abs(n + i - s)), Math.abs(n + s - i)); int dt = Math.min(Math.min(Math.abs(i - t), Math.abs(n + i - t)), Math.abs(n + t - i)); if (ds < dt) x += a[i]; if (ds > dt) y += a[i]; if (ds == dt) que.add(a[i]); } boolean fs = true; while (!que.isEmpty()) { if (fs) { x += que.poll(); } else { y += que.poll(); } fs = !fs; } System.out.println(x - y); } }