#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1);   const long double eps = 0.0000000001;   const long long INF = 0x3fffffffffffffff;   long long a[200005], sum[200005], n, q, x, y;   long long lowbit(long long now) { return now & -now; }   void add(long long pos, long long v) {     while (pos <= n) {       sum[pos] += v;       pos += lowbit(pos);     }   }   long long query(long long now) {     long long res = 0;     while (now) {       res += sum[now];       now ^= lowbit(now);     }     return res;   }   long long findnext(long long now) {     long long l = now + 1, r = n + 1, v = query(now);     while (l < r) {       long long mid = (l + r) >> 1;       if (query(mid) < v << 1) {         l = mid + 1;       } else {         r = mid;       }     }     return l;   }   signed main() {     ios::sync_with_stdio(false);     cin >> n >> q;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       add(i, a[i]);     }     for (long long i = 1; i <= q; ++i) {       cin >> x >> y;       add(x, -a[x]);       a[x] = y;       add(x, a[x]);       long long now = 1;       bool flag = false;       if (a[1] == 0) {         cout << 1 << endl;         continue;       }       while (now <= n) {         now = findnext(now);         if (now <= n && query(now) == a[now] << 1) {           cout << now << endl;           flag = true;           break;         }       }       if (!flag) {         cout << -1 << endl;       }     }     return 0;   }   