from bisect import bisect_left def main(): length, start = map(int, input().split()) start -= 1 coins = [int(x) for x in input().split()] only_1_coin_index = [] for i in range(length): if i == start: continue if coins[i] == 1: only_1_coin_index.append(i) answer = 0 if coins[start] > 1: nearest_1_coin = bisect_left(only_1_coin_index, start) if nearest_1_coin == 0: answer = max(sum(coins[:start + 1]), sum(coins[start: only_1_coin_index[0] + 1])) elif nearest_1_coin == len(only_1_coin_index): answer = max(sum(coins[only_1_coin_index[0]:start + 1]), sum(coins[start:])) else: left = only_1_coin_index[nearest_1_coin - 1] right = only_1_coin_index[nearest_1_coin] answer = sum(coins[left:right + 1]) print(answer) if __name__ == '__main__': main()