#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2 * MOD;
int n, m;
int main() {
  std::ios_base::sync_with_stdio(false);
  set<int> zeros[17];
  cin >> n >> m;
  vector<int> a(n + 1);
  for (int i = 0; i < 17; ++i) {
    zeros[i].insert(0);
    zeros[i].insert(n + 1);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 17; ++j) {
      if (!(a[i] & (1 << j))) {
        zeros[j].insert(i);
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < 17; ++i) {
    set<int>::iterator itr = zeros[i].begin();
    set<int>::iterator nxt = std::next(itr);
    while (nxt != zeros[i].end()) {
      int v = *nxt - *itr - 1;
      sum += (1 << i) * static_cast<long long>(v) * (v + 1) / 2;
      ++itr, ++nxt;
    }
  }
  for (int q = 0; q < m; ++q) {
    int pos, newElement;
    cin >> pos >> newElement;
    for (int i = 0; i < 17; ++i) {
      int l, r;
      if ((a[pos] & (1 << i)) == 0 && (newElement & (1 << i)) != 0) {
        zeros[i].erase(pos);
        set<int>::iterator lower = std::prev(zeros[i].lower_bound(pos));
        set<int>::iterator upper = zeros[i].upper_bound(pos);
        l = pos - *lower - 1;
        r = *upper - pos - 1;
        sum += (1 << i) * (1 + l + r + static_cast<long long>(l) * r);
      }
      if ((a[pos] & (1 << i)) != 0 && (newElement & (1 << i)) == 0) {
        set<int>::iterator lower = std::prev(zeros[i].lower_bound(pos));
        set<int>::iterator upper = zeros[i].upper_bound(pos);
        l = pos - *lower - 1;
        r = *upper - pos - 1;
        sum -= (1 << i) * (1 + l + r + static_cast<long long>(l) * r);
        zeros[i].insert(pos);
      }
    }
    cout << sum << '\n';
    a[pos] = newElement;
  }
  cout.flush();
  return 0;
}
