#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[i]; if(a[k] == 0) { cout << 0 << endl; return 0; } long long ans = a[k]; int pos = k; while(pos && a[pos - 1]) { pos--; ans += a[pos]; if(a[pos] == 1) break; } pos = k; while(pos < n - 1 && a[pos + 1]) { pos++; ans += a[pos]; if(a[pos] == 1) break; } cout << ans << endl; }