#include <bits/stdc++.h>
const int N = 100100;
using namespace std;
struct node {
  int a, b, lm, rm;
  long long cnt;
  node *l, *r;
};
struct linetree {
  node tree[N + N];
  node *Root;
  int pos, n;
  inline void init(int x) {
    n = x;
    Root = built(1, n);
  }
  inline void push(int x, int t) { insert(Root, x, t); }
  long long calc(int x) {
    long long y = x;
    return y * (y + 1) / 2;
  }
  node *built(int a, int b) {
    node *root = &tree[pos++];
    root->a = a;
    root->b = b;
    if (a == b) return root;
    int mid = (a + b) >> 1;
    root->l = built(a, mid);
    root->r = built(mid + 1, b);
    return root;
  }
  void insert(node *root, int x, int t) {
    if (root->a == root->b && root->a == t) {
      root->cnt = root->lm = root->rm = x;
      return;
    }
    int mid = (root->a + root->b) >> 1;
    if (t > mid)
      insert(root->r, x, t);
    else
      insert(root->l, x, t);
    root->cnt = root->l->cnt + root->r->cnt;
    if (root->l->rm && root->r->lm)
      root->cnt += -calc(root->l->rm) - calc(root->r->lm) +
                   calc(root->l->rm + root->r->lm);
    root->lm = root->l->lm;
    if (root->l->lm == mid - root->a + 1) root->lm += root->r->lm;
    root->rm = root->r->rm;
    if (root->r->rm == root->b - mid) root->rm += root->l->rm;
  }
  inline long long get() { return Root->cnt; }
} line[20];
int main() {
  int n, m, x, y;
  long long ans;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 20; i++) line[i].init(n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (int j = 0; j < 20; j++)
      if (x & (1 << j)) line[j].push(1, i);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    ans = 0;
    for (int j = 0; j < 20; j++) {
      line[j].push((y >> j) & 1, x);
      ans += line[j].get() << j;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
