#include #define MOD 1000000007LL using namespace std; typedef long long ll; typedef pair P; int n,s,t; ll a[100005]; ll dp[100005]; vector

vec; ll get_len(int p1,int p2){ if(p1>p2)swap(p1,p2); return min(p2-p1,p1+n-p2); } int main(void){ scanf("%d",&n); scanf("%d%d",&s,&t); s--; t--; ll ans=0; vector v; for(int i=0;iget_len(t,i)){ ans-=a[i]; }else{ v.push_back(a[i]); } } sort(v.begin(),v.end()); reverse(v.begin(),v.end()); ans+=v[0]; if(v.size()>=2){ ans-=v[1]; } printf("%lld\n",ans); return 0; }