#include <bits/stdc++.h>

using namespace std;

void ispisi(vector<int> a)
{
    for(int i = 0;i<a.size();i++)
        cout << a[i] << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int N,K;
    cin >> N >> K;

    vector<int> a(N);

    for(int i = 0;i<N;i++)
    {
        cin >> a[i];
    }

    while(a.size() != 2)
    {
        int pom = a[0] - a[a.size()-1]; // poslednji u prvi

        if(abs(a[a.size()-2] - pom) < abs(a[1] - pom))
        {
             a[a.size()-1] = -1 * pom;
            a.erase(a.begin());
            //cout << "Usao 2" << endl;
        }
        else
        {
            a[0] = pom;
            a.erase(a.end() - 1);
            //cout << "Usao 1"<< endl;
        }

        //ispisi(a);
    }

    cout << abs(a[0]) + abs(a[1]) << endl;

    return 0;
}