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

//      Starting Kit     (START)
typedef long long ll;
#define INF INT_MAX
#define MOD (1e9+7)

#define pii pair<int, int>
#define mp make_pair

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vii vector<pii>
#define pb push_back
#define print_vect(v) for (auto it : v) cout << it << " ";
//      Starting Kit     (END)

int n, k;

int solve(vi napitak, int op) {

    if (napitak.size() == 1) return napitak[0];

    if (op == 1) {
        napitak[0] = napitak[0]-napitak.back();
        napitak.pop_back();
        return max(solve(napitak, 1), solve(napitak, 2));
    } else {
        napitak.back() = napitak.back()-napitak[0];
        napitak.erase(napitak.begin());
        return max(solve(napitak, 1), solve(napitak, 2));
    }
}

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

    cin >> n >> k;
    vi napitak(n);

    for (int i = 0; i < n; ++i) cin >> napitak[i];

    // n == k
    cout << max(solve(napitak, 1), solve(napitak, 2)) << endl;

    return 0;
}