#include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, k; long long int t; vector v; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> t; v.push_back(t); } k -= 1; if (v[k] == 0) { cout << 0 << '\n'; return 0; } long long int R = 0; long long int L = 0; for (int i = k + 1; i < n; i++) { if (v[i] <= 1) { R += v[i]; break; } R += v[i]; } for (int i = k - 1; i >= 0; i--) { if (v[i] <= 1) { L += v[i]; break; } } if (v[k] == 1) { cout << max(L, R) + 1 << '\n'; } else { cout << L + R + v[k] << '\n'; } return 0; }