#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 10;
const long long INF = 4e18 + 10;
const int maxn = 1e5 + 5;
const int maxbit = 32;
struct Block {
  int lb, rb, sz;
  bool operator<(const Block& rhs) const {
    if (lb != rhs.lb)
      return lb < rhs.lb;
    else if (rb != rhs.rb)
      return rb < rhs.rb;
    return sz < rhs.sz;
  }
};
long long sum(int x) { return (1LL * x * (x + 1)) / 2; }
void print(int* a, int n) {
  for (int i = 0; i < n; ++i) printf("%d", a[i]);
  puts("");
}
int series[32][maxn];
set<Block> blocks[32];
int a[maxn];
int n, m;
long long tot;
int MAIN() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    for (int bit = 0; bit < maxbit; ++bit) {
      if (a[i] & (1 << bit)) series[bit][i] = 1;
    }
  }
  for (int bit = 0; bit < maxbit; ++bit) {
    int mask = (1 << bit);
    int sz = 1, lft = 0;
    for (int i = 0; i < n; ++i) {
      if (i == n - 1 || series[bit][i] != series[bit][i + 1]) {
        if ((mask & a[i])) {
          blocks[bit].insert((Block){lft, i, sz});
          tot += (1 << bit) * sum(sz);
        }
        sz = 1, lft = i + 1;
      } else {
        ++sz;
      }
    }
  }
  while (m--) {
    int p, v;
    scanf("%d%d", &p, &v);
    --p;
    for (int bit = 0; bit < maxbit; ++bit) {
      int mask = (1 << bit);
      if ((a[p] & mask) == (v & mask)) continue;
      if (v & mask) {
        set<Block>::iterator lft = blocks[bit].lower_bound((Block){p, 0, 0});
        set<Block>::iterator rgt = lft;
        int nw_lft = p, nw_rgt = p, nw_sz = 1;
        bool er = false;
        if (rgt != blocks[bit].end() && rgt->lb == p + 1) {
          nw_sz += rgt->sz;
          nw_rgt = rgt->rb;
          tot -= (mask * sum(rgt->sz));
          er = true;
        }
        if (rgt != blocks[bit].begin()) {
          --lft;
          if (lft->rb == p - 1) {
            nw_sz += lft->sz;
            nw_lft = lft->lb;
            tot -= (mask * sum(lft->sz));
            blocks[bit].erase(lft);
          }
        }
        if (er) blocks[bit].erase(rgt);
        tot += (mask * sum(nw_sz));
        blocks[bit].insert((Block){nw_lft, nw_rgt, nw_sz});
      } else {
        set<Block>::iterator it = blocks[bit].lower_bound((Block){p, 0, 0});
        if (it == blocks[bit].end() || it->lb > p) --it;
        tot -= (mask * sum(it->sz));
        if (p + 1 <= it->rb) {
          int sz = it->rb - p;
          tot += (mask * sum(sz));
          blocks[bit].insert((Block){p + 1, it->rb, sz});
        }
        if (p - 1 >= it->lb) {
          int sz = p - it->lb;
          tot += (mask * sum(sz));
          blocks[bit].insert((Block){it->lb, p - 1, sz});
        }
        blocks[bit].erase(it);
      }
    }
    a[p] = v;
    printf("%I64d\n", tot);
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int ret = MAIN();
  return ret;
}
