from sys import stdin def main(): #入力 readline=stdin.readline N,K=map(int,readline().split()) A=list(map(int,readline().split())) if A[K-1]==0: print(0) elif A[K-1]>=1: left=0 right=0 now=K-1 while now>0: now-=1 left+=A[now] if A[now]==1: break now=K-1 while now