#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
#define inf (ll)1e18+7
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define int ll
const int N = 1e6 + 30;
using namespace std;
int n, s, t;
pair<int, bool> a[N];
ll dp[N];
set<int> st;
main(){
NFS
cin >> n >> s >> t;
for(int i = 1; i <= n; i++){
cin >> a[i].F;
st.insert(a[i].F);
}
if(s == t){
cout << 0;
ioi
}
if(s > t){
a[s].S = 1;
a[t].S = 1;
reverse(a + 1, a + 1 + n);
bool ok = 0;
for(int i = 1; i <= n; i++){
if(a[i].S == 1){
if(ok == 0){
ok = 1;
s = i;
}
else{
t = i;
break;
}
}
}
}
if(sz(st) == 1){
cout << (ll)(t - s) * a[1].F;
ioi
}
if(s == 1){
ll ans = 0;
ll mn = inf;
for(int i = 1; i < t; i++){
mn = min(mn, a[i].F);
ans += mn;
}
cout << (ll)ans;
ioi
}
ll mn = a[s].F;
for(int i = s - 1; i >= 1; i--){
dp[i] += dp[i + 1] + mn;
mn = min(mn, a[i].F);
//cerr << dp[i] << ' ';
}
ll ans = inf;
bool ok = 0;
for(int i = 1; i <= s; i++){
ll sum = 0;
mn = a[i].F;
for(int j = i; j < t; j++){
mn = min(mn, a[j].F);
sum += mn;
//cerr << sum << ' ' << mn << ' ' << i << ' ' << j << '\n';
}
if(ok == 0){
ans = sum + dp[i];
ok = 1;
}
ans = min(ans, sum + dp[i]);
}
cout << (ll)ans;
ioi
}
I3ByYWdtYSBHQ0MgdGFyZ2V0KCJhdngyIikKI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zIikKIAojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KIAojZGVmaW5lIGxsIGxvbmcgbG9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5zID0gbWluKGFucywgc3VtICsgZHBbaV0pOwogICAgfQogICAgCiAgICAKICAgIAogICAgY291dCA8PCAobGwpYW5zOwogICAgCglpb2kKfQ==