#include using namespace std; using lint = long long; const lint inf = 1LL << 60; const lint mod = 1000000007; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); lint n, k; cin >> n >> k; k--; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } lint ret = a[k]; if (a[k] == 0) { cout << 0 << "\n"; return 0; } for (int i = k + 1; i < n; ++i) { ret += a[i]; if (a[i] == 1 || a[i] == 0) break; } for (int i = k - 1; i >= 0; --i) { ret += a[i]; if (a[i] == 1 || a[i] == 0) break; } cout << ret << "\n"; return 0; }