#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  char c = getchar();
  x = 0;
  while (c > '9' || c < '0') c = getchar();
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
}
const int N = 100005, M = 3000005, mod = 1e9 + 7;
int n, m, q, x, y, cnt, a[N], b[N], t[N], f[N], g[N], B[M], BC[M], BCD[M],
    CD[M], D[M], S[M], ls[M], rs[M], ans;
inline void modify(int x) {
  for (int i = x; i <= n; i += (i) & (-(i))) ++t[i];
}
inline void update(int x) {
  S[x] = (S[ls[x]] + S[rs[x]]) % mod;
  B[x] = (B[ls[x]] + B[rs[x]]) % mod;
  D[x] = (D[ls[x]] + D[rs[x]]) % mod;
  BC[x] = (BC[ls[x]] + BC[rs[x]] + (long long)B[ls[x]] * S[rs[x]]) % mod;
  CD[x] = (CD[ls[x]] + CD[rs[x]] + (long long)S[ls[x]] * D[rs[x]]) % mod;
  BCD[x] = (BCD[ls[x]] + BCD[rs[x]] + (long long)BC[ls[x]] * D[rs[x]] +
            (long long)B[ls[x]] * CD[rs[x]]) %
           mod;
}
inline int query(int x) {
  int sum = 0;
  for (int i = x; i; i -= (i) & (-(i))) sum += t[i];
  return sum;
}
inline void change(int l, int r, int s, int x, int y, int d, int &k) {
  if (!k) k = ++cnt;
  int mid = (l + r) / 2;
  if (l == r) {
    B[k] = x;
    D[k] = y;
    S[k] += d;
    return;
  }
  if (s <= mid)
    change(l, mid, s, x, y, d, ls[k]);
  else
    change(mid + 1, r, s, x, y, d, rs[k]);
  update(k);
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(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) {
    f[i] = query(a[i]);
    modify(a[i]);
  }
  memset(t, 0, sizeof(t));
  for (int i = n; i; --i) {
    g[i] = query(a[i]);
    modify(a[i]);
  }
  cnt = m;
  for (int i = 1; i <= n; ++i) {
    (ans += mod - BCD[a[i]]) %= mod;
    change(1, n, i, f[i], g[i], 1, a[i]);
    (ans += BCD[a[i]]) %= mod;
  }
  read(q);
  while (q--) {
    read(x);
    read(y);
    (ans += mod - BCD[a[y]]) %= mod;
    if (x == 1)
      change(1, n, y, 0, 0, -1, a[y]);
    else
      change(1, n, y, f[y], g[y], 1, a[y]);
    (ans += BCD[a[y]]) %= mod;
    printf("%d\n", ans);
  }
  return 0;
}
