#include #include #include #include using namespace std; int main(){ int N, s, t; cin >> N >> s >> t; vector A(N); for(int i = 0; i < N; i++) cin >> A[i]; s--; t--; vector ma1, ma2; if(s < t){ for(int i = s + 1; i < t; i++) ma1.push_back(A[i]); for(int i = 0; i < N - (int)ma1.size() - 2; i++) ma2.push_back(A[(s - 1 - i + N) % N]); } else{ for(int i = s - 1; i > t; i--) ma1.push_back(A[i]); for(int i = 0; i < N - (int)ma1.size() - 2; i++) ma2.push_back(A[(s + 1 + i) % N]); } long long suml = A[s], sumr = A[t]; vector sum1(ma1.size() + 1), sum2(ma2.size() + 1); for(int i = 1; i <= ma1.size(); i++){ sum1[i] = sum1[i - 1] + ma1[i - 1]; } for(int i = 1; i <= ma2.size(); i++){ sum2[i] = sum2[i - 1] + ma2[i - 1]; } long long ans = -1e18; int N1 = ma1.size(), N2 = ma2.size(); if(N1 % 2 == 0 || N2 % 2 == 0){ long long temp1 = suml + sum1[(N1 + 1) / 2] + sum2[(N2 + 1) / 2]; long long temp2 = sumr + sum1[N1] - sum1[(N1 + 1) / 2] + sum2[N2] - sum2[(N2 + 1) / 2]; ans = max(ans, temp1 - temp2); } else{ long long temp1 = suml + sum1[N1 / 2] + sum2[(N2 + 1) / 2]; long long temp2 = sumr + sum1[N1] - sum1[N1 / 2] + sum2[N2] - sum2[(N2 + 1) / 2]; ans = max(ans, temp1 - temp2); temp1 = suml + sum1[(N1 + 1) / 2] + sum2[N2 / 2]; temp2 = sumr + sum1[N1] - sum1[(N1 + 1) / 2] + sum2[N2] - sum2[N2 / 2]; ans = max(ans, temp1 - temp2); } cout << ans << endl; }