#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; int main(){ int n; scanf("%d",&n); int s,t; scanf("%d %d",&s,&t); --s;--t; vector a(n); rep(i,n) scanf("%lld",&a[i]); vector b,c; for(int i=(s+1)%n;i!=t;i=(i+1)%n) b.push_back(a[i]); for(int i=(s-1+n)%n;i!=t;i=(i-1+n)%n) c.push_back(a[i]); if((int)(b.size())%2==0 && (int)(c.size())%2==0){ ll ss = a[s],tt = a[t]; rep(i,b.size()/2) ss += b[i],tt += b[i+(int)(b.size())/2]; rep(i,c.size()/2) ss += c[i],tt += c[i+(int)(c.size())/2]; cout << ss-tt << endl; }else if((int)(c.size())%2==0){ ll ss = a[s],tt = a[t]; rep(i,b.size()/2) ss += b[i],tt += b[i+1+(int)(b.size())/2]; rep(i,c.size()/2) ss += c[i],tt += c[i+(int)(c.size())/2]; ss += b[(int)(b.size())/2]; cout << ss-tt << endl; }else if((int)(b.size())%2==0){ ll ss = a[s],tt = a[t]; rep(i,b.size()/2) ss += b[i],tt += b[i+(int)(b.size())/2]; rep(i,c.size()/2) ss += c[i],tt += c[i+1+(int)(c.size())/2]; ss += c[(int)(c.size())/2]; cout << ss-tt << endl; }else{ ll ss = a[s],tt = a[t]; rep(i,b.size()/2) ss += b[i],tt += b[i+(int)(b.size())/2]; rep(i,c.size()/2) ss += c[i],tt += c[i+(int)(c.size())/2]; ss += max(b[(int)(b.size())/2], c[(int)(c.size())/2]); tt += min(b[(int)(b.size())/2], c[(int)(c.size())/2]); cout << ss-tt << endl; } return 0; }