import sequtils, strutils, algorithm, math, future, sets, tables, hashes, intsets let read = iterator : string {.closure.} = (while true: (for s in stdin.readLine.split : yield s)) var n,k = read().parseint a = newseqwith(n, read().parseint) var l = 0 r = n - 1 for i in 0 ..< n: if a[i] <= 1: if i < k: l = i else: r = i break if a[k - 1] == 0: echo 0 quit() if a[k - 1] == 1: echo max(a[l .. k - 1].sum, a[k - 1 .. r].sum) quit() echo a[l .. r].sum