#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++) #define ALL(x) x.begin(), x.end() using ll = long long; using namespace std; void fc(vector &sxl, vector &sxr, vector &syl, vector &syr, ll &xls, ll &xrs, int &xl, int &xr){ // cerr << xl << " " << xr << endl; // for(ll tmp : sxl) cerr << tmp << " "; // cerr << endl; // for(ll tmp : sxr) cerr << tmp << " "; // cerr << endl; ll mr = sxr.at((sxr.size()+xr)/2) - xrs; ll ml = sxl.at((sxl.size()+xl)/2) - xls; if(mr > ml){ xr++; xrs = sxr.at(xr); syl.pop_back(); }else{ xl++; xls = sxl.at(xl); syr.pop_back(); } } int main(){ int n, s, t; cin >> n >> s >> t; s--; t--; vector a(n); rep(i, n) cin >> a.at(i); vector sxl, sxr, syl, syr; sxl.push_back(a.at(s)); sxr.push_back(a.at(s)); syl.push_back(a.at(t)); syr.push_back(a.at(t)); for(int i = (s-1+n)%n; i != t; i = (i-1+n)%n){ sxl.push_back(sxl.back()+a.at(i)); } for(int i = (s+1)%n; i != t; i = (i+1) % n){ sxr.push_back(sxr.back()+a.at(i)); } for(int i = (t-1+n)%n; i != s; i = (i-1+n)%n){ syl.push_back(syl.back()+a.at(i)); } for(int i = (t+1)%n; i != s; i = (i+1)%n){ syr.push_back(syr.back()+a.at(i)); } int xl = 0, xr = 0, yl = 0, yr = 0; ll xls = a.at(s), xrs = a.at(s), yls = a.at(t), yrs = a.at(t); rep(i, n-2){ if(i % 2 == 0){ fc(sxl, sxr, syl, syr, xls, xrs, xl, xr); }else{ fc(syl, syr, sxl, sxr, yls, yrs, yl, yr); } } ll x = xls + xrs - a.at(s), y = yls + yrs - a.at(t); cout << x - y << endl; return 0; }