#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long M = 1e9 + 7;
const int inf = 1e9;
long long tree[4 * N], a[N];
long long n, q;
void build(int node, int st, int ed) {
  if (st == ed) {
    tree[node] = a[st];
    return;
  }
  int mid = (st + ed) / 2;
  build(2 * node, st, mid);
  build(2 * node + 1, mid + 1, ed);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
void update(int node, int st, int ed, int pos, int val) {
  if (st == ed) {
    a[st] = val;
    tree[node] = val;
    return;
  }
  int mid = (st + ed) / 2;
  if (pos > mid)
    update(2 * node + 1, mid + 1, ed, pos, val);
  else
    update(2 * node, st, mid, pos, val);
  tree[node] = tree[2 * node] + tree[2 * node + 1];
}
long long query(int node, int st, int ed, int l, int r) {
  if (l <= st and ed <= r) return tree[node];
  if (r < st or ed < l) return 0;
  int mid = (st + ed) / 2;
  long long ans = query(2 * node, st, mid, l, r);
  ans += query(2 * node + 1, mid + 1, ed, l, r);
  return ans;
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &q);
  set<long long> st[35];
  long long pos, val;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) continue;
    pos = log2(a[i]);
    st[pos].insert(i);
  }
  build(1, 1, n);
  while (q--) {
    int pos;
    scanf("%d", &pos);
    int val;
    scanf("%d", &val);
    long long original = a[pos];
    update(1, 1, n, pos, val);
    long long ind = 0;
    if (original != 0) {
      ind = log2(original);
      st[ind].erase(pos);
    }
    if (val != 0) {
      ind = log2(val);
      st[ind].insert(pos);
    }
    if (a[1] == 0) {
      printf("1\n");
      continue;
    }
    long long flag = -1;
    for (int i = 0; i < 35; i++) {
      if (st[i].empty()) continue;
      long long ind1 = *st[i].begin();
      st[i].erase(ind1);
      long long ind2 = 0;
      if (!st[i].empty()) ind2 = *st[i].begin();
      st[i].insert(ind1);
      long long sum = query(1, 1, n, 1, ind1 - 1);
      if (sum == a[ind1]) {
        flag = ind1;
        break;
      }
      if (ind2) {
        sum = query(1, 1, n, 1, ind2 - 1);
        if (sum == a[ind2]) {
          flag = ind2;
          break;
        }
      }
    }
    printf("%lld\n", flag);
  }
}
