n, k = map(int, input().split()) A = list(map(int, input().split())) if A[k-1] == 0: print(0) exit() A = [0] + A + [0] #print(A) for i in range(k): if A[i] == 0: p = i q = 0 elif A[i] == 1: p = i q = 1 for i in reversed(range(k+1, n+2)): if A[i] == 0: r = i s = 0 elif A[i] == 1: r = i s = 1 if A[k] >= 2: #print(p, q, r, s) ans = sum(A[p:k])+A[k]+sum(A[k+1:r+1]) print(ans) else: ans += max(sum(A[p:k]), sum(A[k+1:r+1])) + A[k] print(ans)