#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 4e5 + 10;
int n, q;
ll a[N];
vector<pair<ll, ll>> query1;
vector<ll> g;
map<ll, ll> mp;
map<ll, ll> c;
map<ll, ll> d;
map<ll, ll> rev;
ll minux = 0;
struct node {
int l, r;
ll sum1 = 0;
ll sum2 = 0;
} tree[4 * N];
struct ed {
ll first = 0;
ll second = 0;
};
void pushup(int u) {
tree[u].sum1 = tree[u << 1].sum1 + tree[u << 1 | 1].sum1;
tree[u].sum2 = tree[u << 1].sum2 + tree[u << 1 | 1].sum2;
return ;
}
void build(int u, int l, int r) {
//cout << "build:u=" << u << ",l=" << l << ",r=" << r << endl;
if (l == r) {
tree[u] = {l, r, 0, 0};
return ;
}
tree[u].l = l, tree[u].r = r;
int mid = tree[u].l + tree[u].r >> 1;
if (l <= mid) {
build(u << 1, l, mid);
}
if (r > mid) {
build(u << 1 | 1, mid + 1, r);
}
pushup(u);
return ;
}
ed query(int u, int l, int r) {
//cout << "query:u=" << u << ",tree.l=" << tree[u].l << ",tree.r=" << tree[u].r << endl;
//cout << "query:u=" << u << ",l=" << l << ",r=" << r << endl;
if (l <= tree[u].l && tree[u].r <= r) {
ed val;
val.first = tree[u].sum1;
val.second = tree[u].sum2;
return val;
}
int mid = tree[u].l + tree[u].r >> 1;
ll a = 0;
ll b = 0;
if (l <= mid) {
ed val = query(u << 1, l, r);
a += val.first;
b += val.second;
}
if (r > mid) {
ed val = query(u << 1 | 1, l, r);
a += val.first;
b += val.second;
}
ed val;
val.first = a;
val.second = b;
return val;
}
void update(int u, ll x, ll k) {
//cout << "update:u=" << u << ",x=" << x << endl;
if (tree[u].l == tree[u].r && tree[u].l == x) {
tree[u].sum1 = k;
tree[u].sum2 = 1ll * k * rev[x];
/*if (query(1, 1, 6).first - query(1, 1, 5).first == 1) {
cout << "u=" << u << endl;
}*/
return ;
}
int mid = tree[u].l + tree[u].r >> 1;
if (x <= mid) {
update(u << 1, x, k);
} else {
update(u << 1 | 1, x, k);
}
pushup(u);
return ;
}
int main() {
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] <= 0) {
continue;
}
g.push_back(a[i]);
}
for (int i = 1; i <= q; i++) {
ll x;
ll v;
cin >> x >> v;
if (v > 0)
g.push_back(v);
query1.push_back(make_pair(x, v));
}
sort(g.begin(), g.end());
//g.resize(unique(g.begin(),g.end())-g.begin());
for (int i = 0; i < g.size(); i++) {
rev[i + 1] = g[i];
if (mp[g[i]] == 0) {
mp[g[i]] = i + 1;
}
}
build(1, 1, 2 * n);
ll mn = 0;
for (int i = 1; i <= n; i++) {
mn = min(mn, max(0ll, a[i]));
if (a[i] <= 0) {
minux = 1ll * minux + a[i];
continue;
}
update(1, mp[a[i]] + c[a[i]], 1);
c[a[i]]++;
}
for (int i = 0; i < query1.size(); i++) {
int x = query1[i].first;
ll v = query1[i].second;
if (v <= 0) {
if (a[x] <= 0) {
minux = minux - a[x] + v;
a[x] = v;
} else {
update(1, mp[a[x]] + d[a[x]], 0);
d[a[x]]++;
a[x] = v;
minux = 1ll * minux + a[x];
}
} else {
if (a[x] > 0) {
update(1, mp[a[x]] + d[a[x]], 0);
d[a[x]]++;
a[x] = v;
update(1, mp[a[x]] + c[a[x]], 1);
c[a[x]]++;
} else {
minux = 1ll * minux - a[x];
a[x] = v;
update(1, mp[a[x]] + c[a[x]], 1);
c[a[x]]++;
}
}
/*cout << "a[]= " << ' ';
for (int i = 1; i <= 2 * n; i++) {
cout << query(1, 1, i).second - query(1, 1, i - 1).second << ' ';
}
cout << endl;
cout << "cnt[]= " << ' ';
for (int i = 1; i <= 2 * n; i++) {
cout << query(1, 1, i).first - query(1, 1, i - 1).first << ' ';
}
cout << endl;
cout << "minux=" << minux << endl;*/
if (query(1, 1, 1).second + minux > 0) {
cout << 1 << '\n';
continue;
}
int l = 1, r = 2 * n;
int mid;
while (l < r) {
mid = l + r + 1 >> 1;
ed val = query(1, 1, mid);
if (val.second + minux <= 0) {
l = mid;
} else {
r = mid - 1;
}
}
cout << query(1, 1, l).first + 1 << '\n';
}
}
/*
3 5
1 2 3
3 4
2 -2
1 -3
3 1
2 1
*/