#include <bits/stdc++.h>
using namespace std;
const int NUM = 20;
int n, m;
set<int> p[NUM];
long long ans = 0;
long long get(long long a) { return a * (a + 1) / 2; }
void ins(int i, int a) {
  int j;
  for ((j) = (0); (j) != (NUM); ++(j)) {
    set<int>::iterator it = p[j].lower_bound(i);
    if (a & (1 << j) && *it == i) {
      int r = *(++it);
      int l = *(--(--it));
      ans += (get(r - l - 1) - get(i - l - 1) - get(r - i - 1)) << j;
      p[j].erase(i);
    }
    if (!(a & (1 << j)) && *it != i) {
      int r = *it;
      int l = *(--it);
      ans += (-get(r - l - 1) + get(i - l - 1) + get(r - i - 1)) << j;
      p[j].insert(i);
    }
  }
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for ((j) = (0); (j) != (NUM); ++(j))
    for ((i) = (0); (i) <= (n + 1); ++(i)) p[j].insert(i);
  for ((i) = (1); (i) <= (n); ++(i)) {
    int a;
    scanf("%d", &a);
    ins(i, a);
  }
  for ((i) = (1); (i) <= (m); ++(i)) {
    int p, v;
    scanf("%d%d", &p, &v);
    ins(p, v);
    cout << ans << endl;
  }
  return 0;
}
