#include #define rep(a,n) for (ll a = 0; a < (n); ++a) using namespace std; using ll = long long; typedef pair P; typedef pair PP; typedef vector > Graph; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e18; //入力 ll n; ll s,t; vectora; int main(){ cin >> n; cin >> s >> t; s--;t--; a.resize(2*n); rep(i,n)cin>>a[i]; rep(i,n)a[i+n]=a[i]; ll x = 0; ll y = 0; if(swait; ll ns = s+n; int i=0; while((s+i)<=(t-i)){ if(s+i==t-i){ wait.push_back(a[s+i]); break; } x += a[s+i]; y += a[t-i]; i++; } i=1; while((t+i)<=(ns-i)){ if((t+i)==(ns-i)){ wait.push_back(a[t+i]); break; } x += a[ns-i]; y += a[t+i]; i++; } if(wait.size()==1){ x += wait[0]; } if(wait.size()>=2){ x += max(wait[0],wait[1]); y += min(wait[0],wait[1]); } cout << x-y << endl; } else{ vectorwait; ll nt = t+n; int i=0; while((t+i)<=(s-i)){ if(t+i==s-i){ wait.push_back(a[t+i]); break; } y += a[t+i]; x += a[s-i]; i++; } i=1; while((s+i)<=(nt-i)){ if((s+i)==(nt-i)){ wait.push_back(a[s+i]); break; } y += a[nt-i]; x += a[s+i]; i++; } if(wait.size()==1){ x += wait[0]; } if(wait.size()>=2){ x += max(wait[0],wait[1]); y += min(wait[0],wait[1]); } cout << x-y << endl; } return 0; }