#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

int main() {
    int n, k, sum1 = 0, sum2 = 0;
    cin >> n >> k;
    vector<int> niz(n);
    for (int i = 0; i < n; i++)
        cin >> niz[i];
    sort(begin(niz), end(niz));
    vector<int> najmanji = niz;
    sort(begin(niz), end(niz), greater<int>());
    vector<int> najveci = niz;
    int najmanji_el = najmanji[0];
    int najveci_el = najveci[0];
    for (int i = 0; i < k - 1; i++)
        sum1 += abs(najmanji[i]);
    sum1 += -najveci_el;
    for (int i = 0; i < k - 1; i++)
        sum2 += abs(najveci[i]);
    sum2 += -najmanji_el;
    cout << max(sum1, sum2) << endl;
}