#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, w[100005], lw, len, ans;
int a[100005], b[100005];
int tr[100005], e[100005], B[3000005], BC[3000005], BCD[3000005], CD[3000005],
    D[3000005], S[3000005], son[3000005][2];
inline void add(int x) {
  for (; x <= n; x += ((x) & (-x))) tr[x]++;
}
inline int query(int x) {
  int s = 0;
  for (; x; x -= ((x) & (-x))) s += tr[x];
  return s;
}
inline void update(int t) {
  S[t] = (S[(son[t][0])] + S[(son[t][1])]) % 1000000007;
  B[t] = (B[(son[t][0])] + B[(son[t][1])]) % 1000000007;
  D[t] = (D[(son[t][0])] + D[(son[t][1])]) % 1000000007;
  BC[t] = (BC[(son[t][0])] + BC[(son[t][1])] +
           1ll * B[(son[t][0])] * S[(son[t][1])]) %
          1000000007;
  CD[t] = (CD[(son[t][0])] + CD[(son[t][1])] +
           1ll * S[(son[t][0])] * D[(son[t][1])]) %
          1000000007;
  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])]) %
           1000000007;
}
void change(int t, int l, int r, int s, int x, int y, int d) {
  if (l == r) {
    B[t] = x;
    D[t] = y;
    S[t] += d;
    return;
  }
  int mid = (l + r) >> 1, k = (s > mid);
  if (!son[t][k]) son[t][k] = ++len;
  if (!k)
    change((son[t][0]), l, mid, s, x, y, d);
  else
    change((son[t][1]), mid + 1, r, s, x, y, d);
  update(t);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    e[i] = read();
    w[++lw] = e[i];
  }
  sort(w + 1, w + lw + 1);
  lw = unique(w + 1, w + lw + 1) - w - 1;
  for (int i = 1; i <= n; i++) e[i] = lower_bound(w + 1, w + lw + 1, e[i]) - w;
  memset(tr, 0, sizeof tr);
  for (int i = 1; i <= n; i++) {
    a[i] = query(e[i]);
    add(e[i]);
  }
  memset(tr, 0, sizeof tr);
  for (int i = n; i >= 1; i--) {
    b[i] = query(e[i]);
    add(e[i]);
  }
  len = lw;
  for (int i = 1; i <= n; i++) {
    ans = (ans - BCD[e[i]] + 1000000007) % 1000000007;
    change(e[i], 1, n, i, a[i], b[i], 1);
    ans = (ans + BCD[e[i]]) % 1000000007;
  }
  m = read();
  while (m--) {
    int op = read(), x = read();
    ans = (ans - BCD[e[x]] + 1000000007) % 1000000007;
    if (op == 1)
      change(e[x], 1, n, x, 0, 0, -1);
    else
      change(e[x], 1, n, x, a[x], b[x], 1);
    ans = (ans + BCD[e[x]]) % 1000000007;
    printf("%d\n", ans);
  }
  return 0;
}
