#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn], n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long sum = 0;
  for (int i = 0; i < 18; i++) {
    int k = 1 << i;
    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (k & a[j])
        cnt++;
      else {
        sum += 1LL * cnt * (cnt + 1) / 2 * k;
        cnt = 0;
      }
    }
    if (cnt) sum += 1LL * cnt * (cnt + 1) / 2 * k;
  }
  while (m--) {
    int p, v;
    scanf("%d%d", &p, &v);
    for (int i = 0; i < 18; i++) {
      int k = 1 << i;
      if ((k & v) == (k & a[p])) continue;
      int l = 0, r = 0;
      for (int j = p - 1; j >= 1; j--) {
        if (a[j] & k)
          l++;
        else
          break;
      }
      for (int j = p + 1; j <= n; j++) {
        if (a[j] & k)
          r++;
        else
          break;
      }
      long long tmp = (l + r + 1LL * l * r + 1) * k;
      if (k & v)
        sum += tmp;
      else
        sum -= tmp;
    }
    a[p] = v;
    printf("%lld\n", sum);
  }
  return 0;
}
