#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int D = 18;
int cnt[N * D], sump[N * D], sums[N * D], sumL[N * D], sumR[N * D], res[N * D],
    ls[N * D], rs[N * D];
int a[N], b[N], rt[N], pre[N], suf[N];
int n, q, t, treesize, m, x, ans;
void pushup(int now) {
  cnt[now] = cnt[ls[now]] + cnt[rs[now]];
  sump[now] = (sump[ls[now]] + sump[rs[now]]) % mod;
  sums[now] = (sums[ls[now]] + sums[rs[now]]) % mod;
  sumL[now] = ((sumL[ls[now]] + sumL[rs[now]]) % mod +
               1ll * sump[ls[now]] * cnt[rs[now]] % mod) %
              mod;
  sumR[now] = ((sumR[ls[now]] + sumR[rs[now]]) % mod +
               1ll * sums[rs[now]] * cnt[ls[now]] % mod) %
              mod;
  res[now] = ((res[ls[now]] + res[rs[now]]) % mod +
              (1ll * sumL[ls[now]] * sums[rs[now]] % mod +
               1ll * sumR[rs[now]] * sump[ls[now]] % mod) %
                  mod) %
             mod;
}
void update(int& now, int l, int r, int x, int y) {
  if (!now) now = ++treesize;
  if (l == r) {
    sump[now] = pre[l] * y;
    sums[now] = suf[l] * y;
    cnt[now] = y;
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= x)
    update(ls[now], l, mid, x, y);
  else
    update(rs[now], mid + 1, r, x, y);
  pushup(now);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  sort(b + 1, b + 1 + n);
  m = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, b + 1 + m, a[i]) - b;
  for (int i = 1; i <= n; i++) {
    for (int x = a[i]; x; x -= x & -x) pre[i] += res[x];
    for (int x = a[i]; x <= n; x += x & -x) res[x]++;
  }
  memset(res, 0, sizeof(res));
  for (int i = n; i >= 1; i--) {
    for (int x = a[i]; x; x -= x & -x) suf[i] += res[x];
    for (int x = a[i]; x <= n; x += x & -x) res[x]++;
  }
  memset(res, 0, sizeof(res));
  for (int i = 1; i <= n; i++) update(rt[a[i]], 1, n, i, 1);
  for (int i = 1; i <= n; i++) ans = (ans + res[rt[i]]) % mod;
  scanf("%d", &q);
  for (; q; q--) {
    scanf("%d%d", &t, &x);
    t--;
    ans = (ans + mod - res[rt[a[x]]]) % mod;
    update(rt[a[x]], 1, n, x, t);
    ans = (ans + res[rt[a[x]]]) % mod;
    printf("%d\n", ans);
  }
  return 0;
}
