inp = open("robot.in", "r")
outp = open("robot.out", "w")

n, k = map(int, inp.readline().split())

arr = sorted(list(map(int, inp.readline().split())))

s = 0
for i in range(n):
    if (i < k):
        s -= arr[i]
    else:
        s += arr[i]

ans = abs(s)

arr.reverse()

s = 0
for i in range(n):
    if (i < k):
        s -= arr[i]
    else:
        s += arr[i]

ans = max(ans, abs(s))

outp.write(str(ans) + "\n")