#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair int main() { int n, k; cin >> n >> k; vector a(n+2); rep(i,n) cin >> a[i+1]; if (a[k] == 0) { cout << 0 << endl; return 0; } int l = k-1, r = k+1; while (l >= 0 && a[l] > 1) { l--; } while (r < n && a[r] > 1) { r++; } ll ans = 0; if (a[k] >= 2) { for (int i = l; i <= r; i++) ans += a[i]; } else { int cand1 = 0, cand2 = 0; for (int i = l; i <= k; i++) cand1 += a[i]; for (int i = k; i <= r; i++) cand2 += a[i]; ans = max(cand1, cand2); } cout << ans << endl; }