#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7;
long long n, m, ans, x, a[200000], i, j;
set<long long> s[20];
set<long long>::iterator it1, it2;
int main() {
  cin >> n >> m;
  for (j = 0; j < 20; ++j) s[j].insert(0), s[j].insert(n + 1);
  for (i = 1; i <= n; ++i) {
    cin >> a[i];
    for (j = 0; j < 20; ++j)
      if (!(a[i] & (1 << j))) s[j].insert(i);
  }
  for (i = 1; i <= n; ++i)
    for (j = 0; j < 20; ++j)
      if ((a[i] & (1 << j))) {
        it1 = s[j].upper_bound(i);
        ans += (*it1 - i) * (1 << j);
      }
  while (m--) {
    cin >> i >> x;
    for (j = 0; j < 20; ++j)
      if ((a[i] & (1 << j)) && !(x & (1 << j))) {
        s[j].insert(i);
        it1 = it2 = s[j].lower_bound(i);
        --it1;
        ++it2;
        ans -= (1 << j) * (i - *it1) * (*it2 - i);
      } else if (!(a[i] & (1 << j)) && (x & (1 << j))) {
        it1 = it2 = s[j].lower_bound(i);
        --it1;
        ++it2;
        ans += (1 << j) * (i - *it1) * (*it2 - i);
        s[j].erase(i);
      }
    a[i] = x;
    cout << ans << endl;
  }
}
