#include <bits/stdc++.h>
using namespace std;
const int64_t LG = 33;
struct Fen {
  int64_t n;
  vector<int64_t> bt;
  void update(int64_t pos, int64_t val) {
    if (pos <= 0) {
      return;
    }
    while (pos <= n) {
      bt[pos] += val;
      pos = pos + (pos & -pos);
    }
  }
  int64_t ask(int64_t pos) {
    pos = min(pos, n - 1);
    int64_t ans = 0;
    while (pos > 0) {
      ans += bt[pos];
      pos = pos - (pos & -pos);
    }
    return ans;
  }
  void init(int64_t _n) {
    n = _n;
    bt.resize(n + 1);
  }
};
set<int64_t> gr[LG];
int64_t cond[LG][2];
int64_t sum[LG][2];
vector<int64_t> a;
Fen tr;
int64_t ask(int64_t g) {
  for (int64_t i = 0; i < min((size_t)2, gr[g].size()); ++i) {
    if (sum[g][i] == a[cond[g][i]]) {
      return cond[g][i] + 1;
    }
  }
  return -1;
}
int64_t re(int64_t g) {
  int64_t i = 0;
  for (auto it = gr[g].begin(); it != gr[g].end() && i < 2; ++i, ++it) {
    cond[g][i] = *it;
    sum[g][i] = tr.ask(*it);
  }
  return 0;
}
int64_t getGroup(int64_t x) { return x == 0 ? 0 : 1 + getGroup(x / 2); }
signed main() {
  int64_t n, q;
  cin >> n >> q;
  a.resize(n);
  for (auto &el : a) {
    cin >> el;
  }
  for (int64_t i = 0; i < n; ++i) {
    gr[getGroup(a[i])].insert(i);
  }
  tr.init(n);
  for (int64_t i = 0; i < n; ++i) {
    tr.update(i + 1, a[i]);
  }
  for (int64_t i = 0; i < LG; ++i) {
    re(i);
  }
  for (int64_t qq = 0; qq < q; ++qq) {
    int64_t pos, val;
    cin >> pos >> val;
    pos--;
    int64_t diff = val - a[pos];
    gr[getGroup(a[pos])].erase(pos);
    gr[getGroup(val)].insert(pos);
    int64_t was = a[pos];
    a[pos] = val;
    for (int64_t j = 0; j < LG; ++j) {
      for (int64_t i = 0; i < min((size_t)2, gr[j].size()); ++i) {
        if (pos < cond[j][i]) {
          sum[j][i] += diff;
        }
      }
    }
    tr.update(pos + 1, diff);
    re(getGroup(was));
    re(getGroup(val));
    int64_t ans = -1;
    for (int64_t i = 0; i < LG; ++i) {
      ans = max(ans, ask(i));
    }
    cout << ans << endl;
  }
  return 0;
}
