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


int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];

    long long max;
    int i = 0;
    int j = a.size() - 1;
    while(i != j)
    {
        if(a[i] - a[j] > a[j] - a[i])
        {
            a[i] = a[i] - a[j];
            max = a[i];
            j--;
        }
        else
        {
            a[j] = a[j] - a[i];
            max = a[j];
            i++;
        }
    }
    cout << max << endl;
    return 0;
}