#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int MAXBIT = 20;
int n;
int m;
long long a[N];
int p;
long long v;
int seg[MAXBIT][N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  long long ans = 0;
  for (int i = 0; i <= 20; i++) {
    for (int j = 0; j <= n; j++) {
      if ((a[j] & (1 << i)) == 0) {
        long long l = j;
        j++;
        while (a[j] & (1 << i)) j++;
        ans += ((j - l) * (j - l - 1) / 2) * (1 << i);
        j--;
      }
    }
  }
  for (int j = 1; j <= m; j++) {
    scanf("%d%lld", &p, &v);
    for (int i = 0; i <= 20; i++) {
      long long l = p - 1;
      long long r = p + 1;
      while (a[l] & (1 << i)) l--;
      while (a[r] & (1 << i)) r++;
      long long bitp = ((a[p] & (1 << i)) >> i);
      long long bitv = ((v & (1 << i)) >> i);
      if ((bitp == 0) && (bitv == 1)) {
        ans = (ans + (((r - l) * (r - l - 1)) / 2) * (1 << i)) -
              (((((r - p) * (r - p - 1)) / 2) + (((p - l) * (p - l - 1)) / 2)) *
               (1 << i));
      } else if ((bitp == 1) && (bitv == 0)) {
        ans = (ans - ((((r - l) * (r - l - 1)) / 2) * (1 << i))) +
              ((((r - p) * (r - p - 1)) / 2) + (((p - l) * (p - l - 1)) / 2)) *
                  (1 << i);
      }
    }
    a[p] = v;
    printf("%lld\n", ans);
  }
}
