#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; } //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); constexpr long long INF = 1LL << 60; constexpr int inf = 1000000007; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353; constexpr int MAX = 5000000; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; int s, t; cin >> s >> t; s--; t--; ll all = 0; vector a(n); for (int i = 0; i < n; i++) cin >> a[i], all += a[i]; vector b, c; for (int i = s + 1; i < t; i++) { b.emplace_back(a[i]); } for (int i = (s - 1 + n) % n; i != t; i = (i - 1 + n) % n) { c.emplace_back(a[i]); } if (b.size() % 2 == 0 and c.size() % 2 == 0) { ll X = a[s]; for (int i = 0; i < b.size() / 2; i++) X += b[i]; for (int i = 0; i < c.size() / 2; i++) X += c[i]; ll Y = all - X; cout << X - Y << endl; } else if (b.size() % 2 == 0 and c.size() % 2 == 1) { ll X = a[s]; for (int i = 0; i < b.size() / 2; i++) X += b[i]; for (int i = 0; i < c.size() / 2 + 1; i++) X += c[i]; ll Y = all - X; cout << X - Y << endl; } else if (b.size() % 2 == 1 and c.size() % 2 == 0) { ll X = a[s]; for (int i = 0; i < b.size() / 2 + 1; i++) X += b[i]; for (int i = 0; i < c.size() / 2; i++) X += c[i]; ll Y = all - X; cout << X - Y << endl; } else { ll res = -INF; { ll X = a[s]; for (int i = 0; i < b.size() / 2 + 1; i++) X += b[i]; for (int i = 0; i < c.size() / 2; i++) X += c[i]; ll Y = all - X; chmax(res, X - Y); } { ll X = a[s]; for (int i = 0; i < b.size() / 2; i++) X += b[i]; for (int i = 0; i < c.size() / 2 + 1; i++) X += c[i]; ll Y = all - X; chmax(res, X - Y); } cout << res << endl; } return 0; }