#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ int N; cin >> N; int s, t; cin >> s >> t; s--; t--; vector v; rep(i,N){ ll a; cin >> a; v.push_back(a); } vector w; rep(i,N){ w.push_back(v[(s+i)%N]); } s = 0; t = (t+N-s)%N; ll X = v[s], Y = v[t]; int rhs = t-1-s; int lhs = N-2-rhs; if(lhs%2==0 && rhs%2==0){ { int p = s, q = t; while(true){ p++; q--; if(p==(q+1)%N) break; X += v[p]; Y += v[q]; } } { int p = s, q = t; while(true){ p=(p-1+N)%N; q=(q+1)%N; if(q==(p+1)%N) break; X += v[p]; Y += v[q]; } } } if(lhs%2==0 && rhs%2==1){ { int p = s, q = t; while(true){ p++; q--; X += v[p]; if(p==q) break; Y += v[q]; } } { int p = s, q = t; while(true){ p=(p-1+N)%N; q=(q+1)%N; if(q==(p+1)%N) break; X += v[p]; Y += v[q]; } } } if(lhs%2==1 && rhs%2==0){ { int p = s, q = t; while(true){ p++; q--; if(p==(q+1)%N) break; X += v[p]; Y += v[q]; } } { int p = s, q = t; while(true){ p=(p-1+N)%N; q=(q+1)%N; X += v[p]; if(q==p) break; Y += v[q]; } } } if(lhs%2==1 && rhs%2==1){ int pp, qq; { int p = s, q = t; while(true){ p++; q--; if(p==q) break; X += v[p]; Y += v[q]; } pp = p; } { int p = s, q = t; while(true){ p=(p-1+N)%N; q=(q+1)%N; cout << p << " " << q << endl; if(p==q) break; X += v[p]; Y += v[q]; } qq = p; } if(pp > qq){ X += v[pp]; Y += v[qq]; }else{ X += v[qq]; Y += v[pp]; } } cout << X - Y << endl; return 0; }