#include #include using namespace std; typedef long long ll; int main(){ int n, k; cin >> n >> k; k--; int a[n]; for(int i = 0; i < n; i++) cin >> a[i]; if(a[k] == 0){ cout << 0 << endl; }else{ int l = k, r = k; while(l-1 >= 0 && a[l] > 1) l--; while(r+1 < n && a[r] > 1) r++; cout << accumulate(a+l, a+r+1, 0ll) << endl; } return 0; }