#include #include #include #include #include #include #include #include #include #include #define mkp make_pair #define mkt make_tuple #define rep(i,n) for(int i = 0; i < (n); ++i) #define all(v) v.begin(),v.end() using namespace std; typedef long long ll; const ll MOD=1e9+7; template void chmin(T &a,const T &b){if(a>b) a=b;} template void chmax(T &a,const T &b){if(a>N>>S>>T; vector A(N); rep(i,N) cin>>A[i]; S--;T--; auto getD = [&](int a,int b){ int res=abs(a-b); chmin(res,abs(a+N-b)); chmin(res,abs(b+N-a)); return res; }; vector B; for(int i=S;;i=(i-1+N)%N){ if(getD(i,S)<=getD(i,T)) B.push_back(A[i]); else break; } reverse(all(B)); for(int i=S;;i=(i+1)%N){ if(getD(i,S)<=getD(i,T)) B.push_back(A[i]); else break; } int V=B.size(); vector sum(V+1,0); rep(i,V) sum[i+1]=sum[i]+B[i]; ll all=0; rep(i,N) all+=A[i]; int rad=(N+1)/2; ll ans=0; for(int i=rad;i<=V;i++) chmax(ans,sum[i]-sum[i-rad]); ans-=(all-ans); cout<