#include <bits/stdc++.h>
const int maxn = 100050, maxb = 20;
int n, m, d = 17, A[maxn];
long long ans = 0;
int tr[maxn][maxb] = {0};
inline int lowbit(int x) { return x & (-x); }
void cha(int k, int x, int b) {
  while (x <= n) tr[x][b] += k, x += lowbit(x);
}
int que(int x, int b) {
  int s = 0;
  while (x) s += tr[x][b], x -= lowbit(x);
  return s;
}
int main() {
  int d0, i, j, p, v;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &A[i]);
  for (d0 = 0; d0 < d; d0++)
    for (i = 1; i <= n; i++)
      if ((A[i] >> d0) & 1) {
        cha(1, i, d0);
        for (j = i + 1; j <= n && (A[j] >> d0) & 1; j++) cha(1, j, d0);
        ans += ((long long)(j - i) * (j - i + 1) / 2) << d0;
        i = j;
      }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &p, &v);
    for (d0 = 0; d0 < d; d0++)
      if ((v >> d0 & 1) ^ (A[p] >> d0 & 1)) {
        int l = p, r = n, mid, ls, rs;
        while (r > l) {
          mid = (l + r) / 2 + 1;
          if (que(mid, d0) - que(p, d0) == mid - p)
            l = mid;
          else
            r = mid - 1;
        }
        rs = l - p + 1;
        l = 0, r = p - 1;
        while (r > l) {
          mid = (l + r) / 2;
          if (que(p - 1, d0) - que(mid, d0) == p - 1 - mid)
            r = mid;
          else
            l = mid + 1;
        }
        ls = p - l;
        if (A[p] >> d0 & 1)
          ans -= ((long long)ls * rs) << d0, cha(-1, p, d0);
        else
          ans += ((long long)ls * rs) << d0, cha(1, p, d0);
      }
    A[p] = v;
    printf("%I64d\n", ans);
  }
  return 0;
}
