#include "bits/stdc++.h" using namespace std; #define int long long #define REP(i, n) for (int i = 0; i < (int)n; ++i) #define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i) #define FOR(i, s, n) for (int i = s; i < (int)n; ++i) #define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i) #define ALL(a) a.begin(), a.end() #define IN(a, x, b) (a <= x && x < b) templateistream&operator >>(istream&is,vector&vec){for(T&x:vec)is>>x;return is;} templateinline void out(T t){cout << t << "\n";} templateinline void out(T t,Ts... ts){cout << t << " ";out(ts...);} templateinline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;} templateinline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;} constexpr int INF = 1e18; signed main(){ int N; cin >> N; int S, T; cin >> S >> T; --S; --T; vectora(N); cin >> a; int init = a[S] - a[T]; vectorl, r; for(int i = S + 1; i % N != T; i++) { l.emplace_back(a[i % N]); } for(int i = S - 1; (i + N) % N != T; i--) { r.emplace_back(a[(i + N) % N]); } //REP(i,l.size())cout << l[i] << " \n"[i+1 == l.size()]; //REP(i,r.size())cout << r[i] << " \n"[i+1 == r.size()]; int s_get = (N - 2 + 1) / 2; //先手の行動回数 l.insert(l.begin(), 0); REP(i, l.size() - 1) l[i + 1] += l[i]; r.insert(r.begin(), 0); REP(i, r.size() - 1) r[i + 1] += r[i]; int sum = l.back() + r.back(); int ans = 0; //out(l.size(), r.size()); REP(i, l.size() / 2 + 1) { if(!IN(0, s_get - i, r.size())) continue; int tmp = l[i] + r[s_get - i]; CHMAX(ans, tmp); } REP(i, r.size() / 2 + 1) { if(!IN(0, s_get - i, l.size())) continue; int tmp = r[i] + l[s_get - i]; CHMAX(ans, tmp); } //out(ans, init); out(ans - (sum - ans) + init); }