#include using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; vector a(n); for(ll i = 0; i < n; i++)cin >> a[i]; k--; if(!a[k]) { cout << 0 << endl; return 0; } ll sr = 0, sl = 0; ll ind = k+1; while(ind < n - 1 && a[ind] >= 2) { sr += a[ind]; ind++; } if(ind < n) sr += a[ind]; ind = k-1; while(ind > 0 && a[ind] >= 2) { sl += a[ind]; ind--; } if(ind >= 0) sl += a[ind]; if(a[k] == 1) { cout << max(sr, sl) + 1 << endl; } else { cout << sr + sl + a[k] << endl; } }