# coding: utf-8 # Your code here! import sys readline = sys.stdin.readline read = sys.stdin.read n,k,*a = [int(i) for i in read().split()] k -= 1 v = 0 rb = 0 for i in range(k+1,n): v += a[i] if a[i] <= 1: rb = v break else: rb = v v = 0 lb = 0 for i in range(k-1,-1,-1): v += a[i] if a[i] <= 1: lb = v break else: lb = v #print(r,rb) #print(l,lb) if a[k] == 0: print(0) elif a[k] == 1: print(a[k]+max(lb,rb)) else: print(a[k]+lb+rb)