#include <iostream>
#include <algorithm>

using namespace std; 

int main()
{
    int n, k; cin >> n >> k;
    int a[200000];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int power = 0;
    int l = 0; int r = n - 1;
    for (int i = 0; i < k; i++)
    {
        if (a[l] > a[r] && a[l]-a[r]>0) {
            a[l] -= a[r];
            r--;
            i++;
            power = a[l];
        }
        if(a[r] > a[l] && a[r] - a[l] > 0){
            a[r] -= a[l];
            l++;
            i++;
            power = a[r];
        }
    }
    cout << power << endl;
}