#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
using namespace ::std;
const long long maxn = 1e5 + 500;
const long long mod = 1e9 + 7;
struct M {
  long long a[5][5];
};
long long ent(long long n, long long k) {
  if (n < 0) return 0;
  if (k == 0) return 1;
  if (k == 1) return n;
  if (k == 2) return (n * (n - 1) / 2) % mod;
  if (k == 3) return ((n * (n - 1) * (n - 2)) / 6) % mod;
  return 0;
}
M merge(M a, M b) {
  M ans;
  for (long long i = 0; i < 5; i++) {
    for (long long j = i; j < 5; j++) {
      ans.a[i][j] = (b.a[i][j] + a.a[i][j]) % mod;
      for (long long k = i; k < j; k++)
        ans.a[i][j] = (ans.a[i][j] + (a.a[i][k] * b.a[k + 1][j])) % mod;
    }
  }
  return ans;
}
M chenge(long long x, long long t) {
  M ans;
  for (long long i = 0; i < 5; i++) {
    for (long long j = 0; j < 5; j++) {
      if (i == j) {
        ans.a[i][j] = t;
      } else if (i < j) {
        ans.a[i][j] = 0;
      }
    }
  }
  ans.a[4][4] = x + 1;
  ans.a[0][0] = 1 + x;
  ans.a[0][1] = x * t;
  return ans;
}
vector<M> seg[maxn];
vector<long long> vec[maxn];
long long sum;
void pri(M a) {
  for (long long i = 0; i < 5; i++) {
    for (long long j = 0; j < i; j++) cout << 0 << ' ';
    for (long long j = i; j < 5; j++) {
      cout << a.a[i][j] << ' ';
    }
    cout << endl;
  }
}
void bild(long long b, long long l = 0, long long r = 0, long long node = 0) {
  if (node == 0) {
    l = 0;
    r = vec[b].size();
    node = 1;
    seg[b].resize(vec[b].size() * 4);
  }
  if (l + 1 == r) {
    if (r == vec[b].size()) {
      seg[b][node] = chenge(vec[b][l], 0);
      seg[b][node].a[0][0]--;
      seg[b][node].a[4][4]--;
    } else {
      seg[b][node] = chenge(vec[b][l], 1);
    }
    return;
  }
  long long mid = (l + r) / 2;
  bild(b, l, mid, 2 * node);
  bild(b, mid, r, 2 * node + 1);
  seg[b][node] = merge(seg[b][2 * node], seg[b][2 * node + 1]);
  if (node == 1) sum += seg[b][node].a[0][4];
}
void update(long long b, long long x, long long t, long long l = 0,
            long long r = 0, long long node = 0) {
  if (node == 0) {
    l = 0;
    r = vec[b].size();
    node = 1;
    sum -= seg[b][node].a[0][4];
  }
  if (l + 1 == r) {
    seg[b][node] = chenge(vec[b][l], t);
    return;
  }
  long long mid = (l + r) / 2;
  if (x < mid) {
    update(b, x, t, l, mid, 2 * node);
  } else {
    update(b, x, t, mid, r, 2 * node + 1);
  }
  seg[b][node] = merge(seg[b][2 * node], seg[b][2 * node + 1]);
  if (node == 1) {
    sum += seg[b][node].a[0][4];
  }
}
long long a[maxn];
long long k[maxn];
long long fen[maxn];
long long last[maxn];
long long chand[maxn];
void updateFen(long long x, long long v) {
  for (x++; x < maxn; x += (x & (-x))) fen[x] += v;
}
long long sumFen(long long x) {
  long long ans = 0;
  for (x++; x; x -= (x & (-x))) ans += fen[x];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> comp;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    comp.push_back(a[i]);
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      for (long long k = j + 1; k < n; k++) {
        for (long long u = k + 1; u < n; u++) {
          for (long long t = u + 1; t < n; t++) {
            res +=
                (a[j] == a[k] && a[k] == a[u] && a[t] <= a[u] && a[i] <= a[j]);
          }
        }
      }
    }
  }
  sort(comp.begin(), comp.end());
  comp.resize(unique(comp.begin(), comp.end()) - comp.begin());
  for (long long i = 0; i < n; i++) {
    a[i] = lower_bound(comp.begin(), comp.end(), a[i]) - comp.begin();
  }
  fill(last, last + maxn, -1);
  for (long long i = 0; i < n; i++) {
    long long v = a[i];
    updateFen(v, 1);
    k[i] = sumFen(v - 1);
    if (last[v] == -1) {
      vec[v].push_back(k[i]);
      chand[i] = 1;
    } else {
      chand[i] = chand[last[v]] + 1;
      vec[v].push_back(k[i] - k[last[v]]);
    }
    last[a[i]] = i;
  }
  for (long long i = 0; i < comp.size(); i++) {
    vec[i].push_back(sumFen(i - 1) - k[last[i]]);
    bild(i);
  }
  long long q;
  cin >> q;
  while (q--) {
    long long t, x;
    cin >> t >> x;
    t--;
    x--;
    update(a[x], chand[x] - 1, t);
    cout << sum % mod << endl;
  }
}
