#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; } for (int i = k + 1; i < n; i++) { ans += a.at(i); if (a.at(i) <= 1) break; } for (int i = k - 1; i >= 0; i--) { ans += a.at(i); if (a.at(i) <= 1) break; } cout << ans << endl; }