#include <bits/stdc++.h>
using namespace std;

int main() {                       
    freopen("robot.in", "r", stdin);
    freopen("robot.out", "w", stdout);
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &x[i]);
    }
    sort(x.begin(), x.end(), [](int a, int b) {return abs(a) > abs(b);});
    int sum1 = 0, sum2 = 0;
    int k1 = k, k2 = k;
    for (auto i = x.begin(); i != x.end(); ++i) {
        int cur = *i;
        if (cur == 0) continue;
        if (cur > 0) sum1 += cur, sum2 += k2-- > 0 ? -cur : cur;
        if (cur < 0) sum2 += cur, sum1 += k1-- > 0 ? -cur : cur; 
    }
    assert(abs(sum1) <= 1000000000 && abs(sum2) <= 1000000000);
    printf("%d\n", max(abs(sum1), abs(sum2)));
    
    return 0;
}