N, K =map(int, input().split()) A = list(map(int, input().split())) K -= 1 ans = A[K] if A[K] != 0: l = r = 0 if K != 0: for i in range(K-1, -1, -1): l += A[i] if A[i] <= 1: break if K != N-1: for i in range(K+1, N): r += A[i] if A[i] <= 1: break if A[K] == 1: ans += max(l, r) else: ans += l + r print(ans)