#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
int n, m, w[100005], lw, a[100005], b[100005], tr[100005], e[100005],
    B[3000005], BC[3000005], BCD[3000005], CD[3000005], D[3000005], S[3000005],
    son[3000005][2], len, ans;
int lowbit(int x) { return x & (-x); }
void modify(int x) {
  while (x <= n) tr[x]++, x += lowbit(x);
}
int query(int x) {
  int s = 0;
  while (x) s += tr[x], x -= lowbit(x);
  return s;
}
void update(int t) {
  S[t] = (S[(son[t][0])] + S[(son[t][1])]) % mo;
  B[t] = (B[(son[t][0])] + B[(son[t][1])]) % mo;
  D[t] = (D[(son[t][0])] + D[(son[t][1])]) % mo;
  BC[t] = (BC[(son[t][0])] + BC[(son[t][1])] +
           1LL * B[(son[t][0])] * S[(son[t][1])]) %
          mo;
  CD[t] = (CD[(son[t][0])] + CD[(son[t][1])] +
           1LL * S[(son[t][0])] * D[(son[t][1])]) %
          mo;
  BCD[t] = (BCD[(son[t][0])] + BCD[(son[t][1])] +
            1LL * BC[(son[t][0])] * D[(son[t][1])] +
            1LL * B[(son[t][0])] * CD[(son[t][1])]) %
           mo;
}
void MOD(int t, int l, int r, int s, int x, int y, int d) {
  int mid = (l + r) >> 1, k = (s > mid);
  if (l == r) {
    B[t] = x, D[t] = y, S[t] += d;
    return;
  }
  if (!son[t][k]) son[t][k] = ++len;
  if (!k)
    MOD((son[t][0]), l, mid, s, x, y, d);
  else
    MOD((son[t][1]), mid + 1, r, s, x, y, d);
  update(t);
}
int main() {
  int i, op, x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &e[i]), w[++lw] = e[i];
  sort(w + 1, w + lw + 1), lw = unique(w + 1, w + lw + 1) - w - 1;
  for (i = 1; i <= n; i++) e[i] = lower_bound(w + 1, w + lw + 1, e[i]) - w;
  memset(tr, 0, sizeof(tr));
  for (i = 1; i <= n; i++) a[i] = query(e[i]), modify(e[i]);
  memset(tr, 0, sizeof(tr));
  for (i = n; i >= 1; i--) b[i] = query(e[i]), modify(e[i]);
  len = lw;
  for (i = 1; i <= n; i++) {
    ans = (ans - BCD[e[i]] + mo) % mo;
    MOD(e[i], 1, n, i, a[i], b[i], 1);
    ans = (ans + BCD[e[i]]) % mo;
  }
  scanf("%d", &m);
  while (m--) {
    scanf("%d %d", &op, &x);
    ans = (ans - BCD[e[x]] + mo) % mo;
    if (op == 1)
      MOD(e[x], 1, n, x, 0, 0, -1);
    else
      MOD(e[x], 1, n, x, a[x], b[x], 1);
    ans = (ans + BCD[e[x]]) % mo;
    printf("%d\n", ans);
  }
  return 0;
}
