#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define tull tuple<ll,ll,ll>
#define pb push_back
#define f first
#define endl "\n"
#define se second
#define piii pair<int,pii>
#define id1 id<<1
#define id2 (id<<1)+1
#define MASK(i) (1<<i)
#define TIME "\nTime elapsed : "<<(double)clock()/1000<<" ms"
#define all(x) x.begin(),x.end()
#define TASK "test"
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 1e16;
const ll maxn = 5e5 + 5;
const ll maxs = 1e7;
const ll dx[] = { -1, 0, 0, 1 };
const ll dy[] = { 0, -1, 1, 0 };
ll n,q;
ll a[maxn];
ll lazy[4 * maxn + 5];
ll st[4 * maxn + 5];
void build(ll id,ll l,ll r)
{
if(l == r){
st[id] = a[l];
return;
}
ll mid = (l + r) >> 1;
build(id * 2,l,mid);
build(id * 2 + 1,mid + 1,r);
st[id] = max(st[id * 2],st[id * 2 + 1]);
}
void down(ll id,ll l,ll r)
{
ll mid = (l + r) >> 1;
st[id * 2] += lazy[id];
lazy[id * 2] += lazy[id];
st[id * 2 + 1] += lazy[id];
lazy[id * 2 + 1] += lazy[id];
lazy[id] = 0;
}
void update(ll id,ll l,ll r,ll u,ll v,ll val)
{
if(v < l || r < u){
return;
}
if(u <= l && r <= v){
st[id] += val;
lazy[id] += val;
return;
}
down(id,l,r);
ll mid = (l + r) >> 1;
update(id * 2,l,mid,u,v,val);
update(id * 2 + 1,mid + 1,r,u,v,val);
st[id] = max(st[id * 2],st[id * 2 + 1]);
}
ll get(ll id,ll l,ll r,ll u,ll v)
{
if(v < l || r < u){
return 0;
}
if(u <= l && r <= v){
return st[id];
}
down(id,l,r);
int mid = (l + r) >> 1;
return max(get(id * 2,l,mid,u,v),get(id * 2 + 1,mid + 1,r,u,v));
}
int main()
{
fast
cin >> n >> q;
for(int i = 1; i <= n; ++i){
cin >> a[i];
}
build(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BuLHE7CmxsIGFbbWF4bl07CmxsIGxhenlbNCAqIG1heG4gKyA1XTsKbGwgc3RbNCAqIG1heG4gKyA1XTsKCnZvaWQgYnVpbGQobGwgaWQsbGwgbCxsbCByKQp7CiAgICBpZihsID09IHIpewogICAgICAgIHN0W2lkXSA9IGFbbF07CiAgICAgICAgcmV0dXJuOwogICAgfQoKICAgIGxsIG1pZCA9IChsICsgcikgPj4gMTsKICAgIGJ1aWxkKGlkICogMixsLG1pZCk7CiAgICBidWlsZChpZCAqIDIgKyAxLG1pZCArIDEscik7CgogICAgc3RbaWRdID0gbWF4KHN0W2lkICogMl0sc3RbaWQgKiAyICsgMV0pOwp9Cgp2b2lkIGRvd24obGwgaWQsbGwgbCxsbCByKQp7CiAgICBsbCBtaWQgPSAobCArIHIpID4+IDE7CiAgICBzdFtpZCAqIDJdICs9IGxhenlbaWRdOwogICAgbGF6eVtpZCAqIDJdICs9IGxhenlbaWRdOwogICAgc3RbaWQgKiAyICsgMV0gKz0gbGF6eVtpZF07CiAgICBsYXp5W2lkICogMiArIDFdICs9IGxhenlbaWRdOwogICAgbGF6eVtpZF0gPSAwOwp9Cgp2b2lkIHVwZGF0ZShsbCBpZCxsbCBsLGxsIHIsbGwgdSxsbCB2LGxsIHZhbCkKewogICAgaWYodiA8IGwgfHwgciA8IHUpewogICAgICAgIHJldHVybjsKICAgIH0KCiAgICBpZih1IDw9IGwgJiYgciA8PSB2KXsKICAgICAgICBzdFtpZF0gKz0gdmFsOwogICAgICAgIGxhenlbaWRdICs9IHZhbDsKICAgICAgICByZXR1cm47CiAgICB9CgogICAgZG93bihpZCxsLHIpOwoKICAgIGxsIG1pZCA9IChsICsgcikgPj4gMTsKICAgIHVwZGF0ZShpZCAqIDIsbCxtaWQsdSx2LHZhbCk7CiAgICB1cGRhdGUoaWQgKiAyICsgMSxtaWQgKyAxLHIsdSx2LHZhbCk7CgogICAgc3RbaWRdID0gbWF4KHN0W2lkICogMl0sc3RbaWQgKiAyICsgMV0pOwp9CgpsbCBnZXQobGwgaWQsbGwgbCxsbCByLGxsIHUsbGwgdikKewogICAgaWYodiA8IGwgfHwgciA8IHUpewogICAgICAgIHJldHVybiAwOwogICAgfQoKICAgIGlmKHUgPD0gbCAmJiByIDw9IHYpewogICAgICAgIHJldHVybiBzdFtpZF07CiAgICB9CgogICAgZG93bihpZCxsLHIpOwogICAgaW50IG1pZCA9IChsICsgcikgPj4gMTsKICAgIHJldHVybiBtYXgoZ2V0KGlkICogMixsLG1pZCx1LHYpLGdldChpZCAqIDIgKyAxLG1pZCArIDEscix1LHYpKTsKfQoKaW50IG1haW4oKQp7CiAgICBmYXN0CgogICAgY2luID4+IG4gPj4gcTsKCiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IG47ICsraSl7CiAgICAgICAgY2luID4+IGFbaV07CiAgICB9CgogICAgYnVpbGQoMSwxLG4pOwoKICAgIHdoaWxlKHEtLSl7CiAgICAgICAgaW50IGk7CiAgICAgICAgY2luID4+IGk7CiAgICAgICAgaWYoaSA9PSAxKXsKICAgICAgICAgICAgbGwgdSx2LHg7CiAgICAgICAgICAgIGNpbiA+PiB1ID4+IHYgPj4geDsKICAgICAgICAgICAgdXBkYXRlKDEsMSxuLHUsdix4KTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgaW50IHUsdjsKICAgICAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICAgICAgY291dCA8PCBnZXQoMSwxLG4sdSx2KSA8PCBlbmRsOwogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gMDsKfQo=