#include <bits/stdc++.h>
#define en '\n'
#define ll long long
#define sp " "

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    deque<int> a;
    deque<int> b;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        a.push_back(x);
        b.push_back(x);
    }
    while (a.size() > 1)
    {
        a.back() -= a.front();
        a.pop_front();
        b.front() -= b.back();
        b.pop_back();
    }
    cout << max(abs(a.back()),abs(b.back()));
}