#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int M = 17;
inline long long getsum(long long n) { return (n + 1) * n / 2; }
int n, m, a[N];
set<int> s[M];
long long sum[M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    for (int j = 0; j < M; ++j) {
      if (!(a[i] >> j & 1)) {
        s[j].insert(i);
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    s[i].insert(-1);
    s[i].insert(n);
    int pre = -1;
    set<int>::iterator it = s[i].begin();
    for (++it; it != s[i].end(); pre = *it, ++it) {
      sum[i] += getsum(*it - pre - 1);
    }
  }
  for (int p, v, i = 0; i < m; ++i) {
    scanf("%d%d", &p, &v);
    --p;
    long long ans = 0;
    for (int j = 0; j < M; ++j) {
      int pre = a[p] >> j & 1;
      int cur = v >> j & 1;
      if (pre != cur) {
        if (cur) {
          set<int>::iterator it = s[j].find(p);
          set<int>::iterator prev = it, next = it;
          int l = *--prev, r = *++next;
          sum[j] -= getsum(p - l - 1);
          sum[j] -= getsum(r - p - 1);
          sum[j] += getsum(r - l - 1);
          s[j].erase(it);
        } else {
          set<int>::iterator it = s[j].upper_bound(p);
          int r = *it;
          int l = *--it;
          sum[j] += getsum(p - l - 1);
          sum[j] += getsum(r - p - 1);
          sum[j] -= getsum(r - l - 1);
          s[j].insert(p);
        }
      }
      ans += sum[j] << j;
    }
    printf("%I64d\n", ans);
    a[p] = v;
  }
}
