#include #include #include #include #include #include using namespace std; using ll = int64_t; #define rep(i, j, n) for (int i = j; i < (int)n; ++i) int main() { int n, s, t; cin >> n >> s >> t; --s, --t; vector a(n); for (ll& x : a) cin >> x; vector x, y; for (int i = (s + 1) % n; i != t; i = (i + 1) % n) x.push_back(a[i]); for (int i = (t + 1) % n; i != s; i = (i + 1) % n) y.push_back(a[i]); reverse(y.begin(), y.end()); int xs = (int)x.size(); int ys = (int)y.size(); ll vs = a[s], vt = a[t]; if (xs % 2 == 0) { rep(i, 0, xs / 2) vs += x[i]; rep(i, xs / 2, xs) vt += x[i]; } else { rep(i, 0, xs / 2 + 1) vs += x[i]; rep(i, xs / 2 + 1, xs) vt += x[i]; } if (ys % 2 == 0) { rep(i, 0, ys / 2) vs += y[i]; rep(i, ys / 2, ys) vt += y[i]; } else { rep(i, 0, ys / 2 + 1) vs += y[i]; rep(i, ys / 2 + 1, xs) vt += y[i]; } if (xs & 1 && ys & 1) { ll mn = min(x[xs / 2], y[ys / 2]); vs -= mn; vt += mn; } cout << vs - vt << endl; return 0; }