#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int BIT = 18;
struct Node {
  int ls, rs;
  bool all;
  long long val;
  Node() {}
  Node(int ls, int rs, bool all, int val)
      : ls(ls), rs(rs), all(all), val(val) {}
};
Node merge(Node a, Node b) {
  Node c;
  c.ls = a.all ? a.ls + b.ls : a.ls;
  c.rs = b.all ? a.rs + b.rs : b.rs;
  c.all = a.all && b.all;
  c.val = a.val + b.val + (long long)a.rs * b.ls;
  return c;
}
Node f[BIT][N << 2];
void update(Node* t, int p, int v, int l, int r, int rt) {
  if (l == r) {
    t[rt] = Node(v, v, v, v);
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m)
    update(t, p, v, l, m, (rt << 1));
  else
    update(t, p, v, m + 1, r, (rt << 1 | 1));
  t[rt] = merge(t[(rt << 1)], t[(rt << 1 | 1)]);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    for (int k = 0; k < BIT; k++) update(f[k], i, (a >> k) & 1, 1, n, 1);
  }
  for (int i = 0; i < m; i++) {
    int p, v;
    scanf("%d%d", &p, &v);
    long long ans = 0;
    for (int k = 0; k < BIT; k++) {
      update(f[k], p, (v >> k) & 1, 1, n, 1);
      ans += f[k][1].val << k;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
