#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100100, MAXR = 320;
long long n, m, ans, lb, v[MAXN];
bool on[MAXN][20];
long long g(long long x, long long bit) {
  if (x % 2 == 0) return (x / 2ll) * (x + 1ll) * (1ll << bit);
  return ((x + 1ll) / 2ll) * x * (1ll << bit);
}
struct block {
  bool f, a[MAXR];
  long long l, r, id, bit, sz;
  block(long long l, long long r, long long bit, long long aux)
      : l(l), r(r), bit(bit), id(aux), f(0) {
    for (long long i = l, pos = 0; i <= r; i++, pos++)
      a[pos] = on[i][bit], f = (a[pos] == 0 ? 1 : f), sz = pos;
    sz++;
  }
  block(){};
} b[MAXR][20];
void update(long long pos, long long x, long long id, long long bit,
            long long sz) {
  if (b[id][bit].a[pos] == x) return;
  long long lz = -1ll, rz = n;
  for (long long i = pos - 1ll; i >= 0; i--)
    if (b[id][bit].a[i] == 0) {
      lz = MAXR * id + i;
      break;
    }
  if (lz == -1ll && id != 0) {
    long long aux = id - 1ll;
    while (aux >= 0 && b[aux][bit].f == 0ll) aux--;
    if (aux == -1ll)
      lz = -1ll;
    else
      for (long long i = b[aux][bit].sz - 1ll; i >= 0; i--)
        if (b[aux][bit].a[i] == 0) {
          lz = MAXR * aux + i;
          break;
        }
  }
  for (long long i = pos + 1ll; i < sz; i++)
    if (b[id][bit].a[i] == 0) {
      rz = MAXR * id + i;
      break;
    }
  if (rz == n && id != lb) {
    long long aux = id + 1ll;
    while (aux <= lb && b[aux][bit].f == 0ll) aux++;
    if (aux > lb)
      rz = n;
    else
      for (long long i = 0; i < b[aux][bit].sz; i++)
        if (b[aux][bit].a[i] == 0) {
          rz = MAXR * aux + i;
          break;
        }
  }
  b[id][bit].a[pos] = x;
  if (b[id][bit].a[pos] == 1ll) {
    pos = MAXR * id + pos;
    ans -= g(pos - lz - 1ll, bit) + g(rz - pos - 1ll, bit);
    ans += g(rz - lz - 1ll, bit);
  } else {
    pos = MAXR * id + pos;
    ans += g(pos - lz - 1ll, bit) + g(rz - pos - 1ll, bit);
    ans -= g(rz - lz - 1ll, bit);
  }
  bool ok = 0;
  for (long long i = 0; i < sz; i++)
    if (b[id][bit].a[i] == 0) ok = b[id][bit].f = 1ll;
  if (!ok) b[id][bit].f = 0;
}
signed main() {
  scanf("%lld %lld", &n, &m);
  long long auxl = 0, auxr = 0, aux = 0;
  lb = (n - 1ll) / MAXR;
  for (long long i = 0; i < n; i++, auxr++) {
    scanf("%lld", &v[i]);
    for (long long j = 0; j < 20; j++) on[i][j] = ((v[i] >> j) & 1ll);
    if ((i % MAXR == 0 && i != 0) || i == n - 1ll) {
      for (long long j = 0; j < 20; j++)
        b[aux][j] = block(auxl, auxr - (i != n - 1ll), j, aux);
      aux++;
      auxl = i;
    }
  }
  for (long long j = 0; j < 20; j++) {
    vector<long long> k;
    for (long long i = 0; i < n; i++) {
      if (((v[i] >> j) & 1ll) && (i == 0 || !((v[i - 1ll] >> j) & 1ll)))
        k.push_back(i);
      if (((v[i] >> j) & 1ll) && (i == n - 1ll || !((v[i + 1ll] >> j) & 1ll)))
        k.push_back(i);
    }
    if (k.size() == 0) continue;
    for (long long i = 0; i < k.size(); i += 2)
      ans += g(k[i + 1ll] - k[i] + 1ll, j);
  }
  while (m--) {
    long long p, x;
    scanf("%lld %lld", &p, &x), p--;
    for (long long i = 0; i < 20; i++)
      update(p % MAXR, (x >> i) & 1ll, p / MAXR, i, b[p / MAXR][i].sz);
    printf("%lld\n", ans);
  }
}
