import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) A=[int(i) for i in input().split()] if A[k-1]<=1: print(A[k-1]) else: ans=A[k-1] ans_l,ans_r=0,0 l,r=1,1 while k-1-l>=0: if A[k-1-l]>=2: ans_l+=A[k-1-l] l+=1 continue else: ans_l+=A[k-1-l] break while k-1+r=2: ans_r+=A[k-1+r] r+=1 continue else: ans_r+=A[k-1+r] break if A[k-1]==1: print(ans+max(ans_l,ans_r)) else: print(ans+ans_l+ans_r)