#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::endl; using std::cin; template std::vector make_v(size_t a){return std::vector(a);} template auto make_v(size_t a,Ts... ts){ return std::vector(ts...))>(a,make_v(ts...)); } int main() { int n, k; scanf("%d%d", &n, &k); k--; std::vector a(n); for(int i = 0; i < n; i++) scanf("%lld", &a[i]); if(!a[k]) { printf("0\n"); return 0; } i64 ans = a[k]; for(int i = k; i + 1 < n; i++) { if(a[i + 1] == 1) { ans += 1; break; } ans += a[i + 1]; } for(int i = k; i - 1 >= 0; i--) { if(a[i - 1] == 1) { ans += 1; break; } ans += a[i - 1]; } printf("%lld\n", ans); return 0; }