#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define llint long long #define inf 1e18 #define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++) #define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) using namespace std; typedef pair P; llint n; llint s, t; llint a[100005]; vector vec, vec2; llint calc(vector &vec, vector &vec2) { llint x = vec.size(), y = vec2.size(), ret = 0; for(int i = 0; i < x; i++){ if(i < (x+1)/2) ret += vec[i]; else ret -= vec[i]; } if(x % 2){ for(int i = 0; i < y; i++){ if(i < y/2) ret += vec2[i]; else ret -= vec2[i]; } } else{ for(int i = 0; i < y; i++){ if(i < (y+1)/2) ret += vec2[i]; else ret -= vec2[i]; } } return ret; } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; cin >> s >> t; s--, t--; for(int i = 0; i < n; i++) cin >> a[i]; llint ans = a[s] - a[t]; for(int i = (s+1)%n; i != t; i = (i+1)%n) vec.push_back(a[i]); for(int i = (t+1)%n; i != s; i = (i+1)%n) vec2.push_back(a[i]); ans += max(calc(vec, vec2), calc(vec2, vec)); cout << ans << endl; return 0; }