n,k = map(int,input().split()) a = [int(i) for i in input().split()] if a[k-1] == 0: print(0) exit() l = 0 now = k-2 for i in range(n): if now != -1: if a[now] > 1: l += a[now] else: l += a[now] break now -= 1 r = 0 now = k for i in range(n): if now != n: if a[now] > 1: r += a[now] else: r += a[now] break now += 1 #print(r) if a[k-1] == 1: print(max(r,l,a[k-1])) else: print(r+l+a[k-1])