#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef pair<ll,pair<ll,ll> > Type;
  int segn2;
  vector<Type> data;
  vector<ll> s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, {0, {LLINF, -LLINF}});

    for(int i=segn2-1; i<segn2+n-1; i++)
      data[i] = {0, {0, 0}};

    for(int i=segn2-2; i>=0; i--) {
      data[i] = merge(data[i*2+1], data[i*2+2]);
    }

    s_data.assign(segn2*2, 0);
  }

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return {0, {LLINF, -LLINF}}; //大きさに注意
    if(a <= l && r <= b) return {data[k].first, {data[k].second.first + s_data[k], data[k].second.second + s_data[k]}};

    auto res = merge(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2));
    return  {res.first, {res.second.first + s_data[k], res.second.second + s_data[k]}};
  }

  //add x to [a,b)
  Type add(int a, int b, ll x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b)
      s_data[k] += x;
    else if(a < r && l < b)
      data[k] = merge(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));

    return {data[k].first, {data[k].second.first + s_data[k], data[k].second.second + s_data[k]}};
  }
};


int main(){
  int N, Q;
  int a[SIZE];

  scanf("%d%d", &N, &Q);

  for(int i=0; i<N; i++) scanf("%d", a+i);

  auto f = [](pair<ll,pair<ll, ll> > a, pair<ll,pair<ll,ll> > b){
             pair<ll,pair<ll, ll>> res;
             res.first = max({a.first, b.first, b.second.second - a.second.first});
             res.second.first = min({a.second.first, b.second.first});
             res.second.second = max({a.second.second, b.second.second});

             return res;
           };

  StarrySkyTree seg(f, N+1);

  for(int i=0; i<N; i++) {
    seg.add(i+1, N+1, a[i]);
  }

  auto res = seg.query(0, N);
  printf("%lld\n", res.first);


  for(int i=0; i<Q; i++) {
    int k, x;

    scanf("%d%d", &k, &x);

    seg.add(k, N+1, x - a[k-1]);
    a[k-1] = x;

    auto res = seg.query(0, N+1);
    debug(res);
    printf("%lld\n", res.first);
  }



  return 0;
}



Measured memory_bytes: 11552