# coding: utf-8 # Your code here! N,K=map(int,input().split()) def kill(lis): lis_index=len(lis) for i in range(len(lis)): if lis[i]==0: lis_index==i break elif lis[i]==1: lis_index=i break return lis[:lis_index+1] A=[0]+list(map(int,input().split()))+[0] L=A[:K] #print(len(L)) #print(len(kill(L[::-1]))) R=A[K+1:] #print(len(R)) #print(len(kill(R))) score=[sum(kill(L[::-1])),sum(kill(R))] if A[K]>=2: print(sum(score)+A[K]) elif A[K]==1: print(max(score)+A[K]) else: print(0)