#include <bits/stdc++.h>
using namespace std;
namespace cxcyl {
int n, q, a[500005], minx[4100005], tag[4100005], cnt[4100005];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > -1 && c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  if (c == -1) return 0;
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x * f;
}
inline void up(int p) {
  if (minx[p << 1] == minx[p << 1 | 1])
    minx[p] = minx[p << 1], cnt[p] = cnt[p << 1] + cnt[p << 1 | 1];
  else if (minx[p << 1] < minx[p << 1 | 1])
    minx[p] = minx[p << 1], cnt[p] = cnt[p << 1];
  else
    minx[p] = minx[p << 1 | 1], cnt[p] = cnt[p << 1 | 1];
}
inline void down(int p) {
  tag[p << 1] += tag[p];
  minx[p << 1] += tag[p];
  tag[p << 1 | 1] += tag[p];
  minx[p << 1 | 1] += tag[p];
  tag[p] = 0;
}
void addw(int p, int l, int r, int x, int d) {
  if (l == r) {
    cnt[p] += d;
    return;
  }
  int mid = l + r >> 1;
  down(p);
  if (x <= mid)
    addw(p << 1, l, mid, x, d);
  else
    addw(p << 1 | 1, mid + 1, r, x, d);
  up(p);
}
void add(int p, int l, int r, int L, int R, int d) {
  if (l > R || L > r || L > R) return;
  if (L <= l && r <= R) {
    tag[p] += d;
    minx[p] += d;
    return;
  }
  down(p);
  int mid = l + r >> 1;
  add(p << 1, l, mid, L, R, d);
  add(p << 1 | 1, mid + 1, r, L, R, d);
  up(p);
}
int qry(int p, int l, int r, int L, int R) {
  if (l > R || L > r || L > R) return 0;
  if (L <= l && r <= R) return minx[p] == 1 ? cnt[p] : 0;
  down(p);
  int mid = l + r >> 1;
  return qry(p << 1, l, mid, L, R) + qry(p << 1 | 1, mid + 1, r, L, R);
}
inline int main() {
  n = read(), q = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
    addw(1, 1, 1000001, a[i], 1);
  }
  a[0] = 1000001;
  a[n + 1] = 0;
  for (int i = 0; i <= n; ++i) add(1, 1, 1000001, a[i + 1] + 1, a[i], 1);
  while (q--) {
    int x = read(), y = read();
    add(1, 1, 1000001, a[x] + 1, a[x - 1], -1);
    add(1, 1, 1000001, a[x + 1] + 1, a[x], -1);
    addw(1, 1, 1000001, a[x], -1);
    a[x] = y;
    add(1, 1, 1000001, a[x] + 1, a[x - 1], 1);
    add(1, 1, 1000001, a[x + 1] + 1, a[x], 1);
    addw(1, 1, 1000001, a[x], 1);
    printf("%d\n", qry(1, 1, 1000001, 1, 1000000));
  }
  return 0;
}
}  // namespace cxcyl
int main() { return cxcyl::main(); }
