N, K = map(int, input().split()) K -= 1 A = list(map(int, input().split())) j = K cl = 0 while 0 < j: j -= 1 cl += A[j] if A[j] <= 1: break j = K cr = 0 while j < N - 1: j += 1 cr += A[j] if A[j] <= 1: break if A[K] == 0: print(0) elif A[K] == 1: print(A[K] + max(cl, cr)) else: print(A[K] + cl + cr)