#include using namespace std; int main() { int n, k; cin >> n >> k; k--; vector a(n); for (int i = 0; i < n; i++) cin >> a.at(i); int64_t ans = a.at(k); if (a.at(k) == 0) { cout << 0 << endl; return 0; } int64_t ansr = 0, ansl = 0; for (int i = k + 1; i < n; i++) { ansr += a.at(i); if (a.at(i) <= 1) break; } for (int i = k - 1; i >= 0; i--) { ansl += a.at(i); if (a.at(i) <= 1) break; } if (ans == 1) { ans += max(ansl, ansr); } else { ans += ansl + ansr; } cout << ans << endl; }