#include <bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int n, m, a[100005];
long long calc(int y, int x) {
  int cnt = y - x - 1;
  return cnt * (cnt + 1ll) / 2;
}
int main() {
  long long ans = 0;
  set<int> v[17];
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int o = 0; o <= 16; o++) {
    v[o].insert(0);
    v[o].insert(n + 1);
    int cnt = 0, num = 1 << o;
    for (int i = 1; i <= n; i++)
      if (a[i] & num) {
        cnt++;
      } else {
        v[o].insert(i);
        ans += cnt * (cnt + 1ll) / 2 * num;
        cnt = 0;
      }
    ans += cnt * (cnt + 1ll) / 2 * num;
  }
  for (int i = 0; i < m; i++) {
    int p, c;
    scanf("%d%d", &p, &c);
    for (int o = 0; o <= 16; o++) {
      int num = 1 << o, tag = c & num;
      if (tag == (a[p] & num)) continue;
      if (tag) {
        auto t = v[o].find(p);
        auto l = t, r = t;
        --l;
        ++r;
        v[o].erase(t);
        ans -= calc(*t, *l) * num;
        ans -= calc(*r, *t) * num;
        ans += calc(*r, *l) * num;
      } else {
        auto t = v[o].insert(p).first;
        auto l = t, r = t;
        --l;
        ++r;
        ans -= calc(*r, *l) * num;
        ans += calc(*t, *l) * num;
        ans += calc(*r, *t) * num;
      }
    }
    a[p] = c;
    printf("%I64d\n", ans);
  }
}
