n, k = map(int, input().split()) A = list(map(int, input().split())) ans = 0 l = 0 if k - 2 >= 0: for i in range(k - 2, -1, -1): l += A[i] if A[i] <= 1: break r = 0 if k < n: for i in range(k, n): r += A[i] if A[i] <= 1: break if A[k - 1] == 0: ans = 0 elif A[k - 1] == 1: ans = A[k -1] + max(l, r) else: ans = A[k -1] + l + r print(ans)