#include <bits/stdc++.h>
using namespace std;
namespace TR {
int val[100010], n;
void add(int x) {
  for (; x <= n; x += (x & (-x))) val[x]++;
}
int qry(int x) {
  int v = 0;
  for (; x; x -= (x & (-x))) v += val[x];
  return v;
}
}  // namespace TR
int ls[100010 * 40], rs[100010 * 40], sx[100010 * 40], sl[100010 * 40],
    sr[100010 * 40], sml[100010 * 40], smr[100010 * 40], res[100010 * 40];
void update(int u) {
  sx[u] = sx[ls[u]] + sx[rs[u]];
  sl[u] = (sl[ls[u]] + sl[rs[u]]) % 1000000007,
  sr[u] = (sr[ls[u]] + sr[rs[u]]) % 1000000007;
  sml[u] = (sml[ls[u]] + sml[rs[u]] + 1ll * sl[ls[u]] * sx[rs[u]]) % 1000000007,
  smr[u] = (smr[ls[u]] + smr[rs[u]] + 1ll * sx[ls[u]] * sr[rs[u]]) % 1000000007;
  res[u] =
      (res[ls[u]] + res[rs[u]] + 1ll * sml[ls[u]] * sr[rs[u]] % 1000000007 +
       1ll * sl[ls[u]] * smr[rs[u]]) %
      1000000007;
}
int cnt = 0;
void insert(int &u, int l, int r, int p, int xl, int xr, int xv) {
  if (!u) u = ++cnt;
  if (l == r) {
    sx[u] = xv, sl[u] = xl, sr[u] = xr;
    return;
  }
  int mid = (l + r) >> 1;
  if (p <= mid)
    insert(ls[u], l, mid, p, xl, xr, xv);
  else
    insert(rs[u], mid + 1, r, p, xl, xr, xv);
  update(u);
}
int root[100010], w[100010], pw[100010];
int pa[100010], pb[100010];
int ans = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]), pw[i] = w[i];
  sort(pw + 1, pw + n + 1);
  int m = unique(pw + 1, pw + n + 1) - pw - 1;
  for (int i = 1; i <= n; i++)
    w[i] = lower_bound(pw + 1, pw + m + 1, w[i]) - pw;
  TR::n = m;
  for (int i = 1; i <= n; i++) pa[i] = TR::qry(w[i]), TR::add(w[i]);
  memset(TR::val, 0, sizeof(TR::val));
  for (int i = n; i; i--) pb[i] = TR::qry(w[i]), TR::add(w[i]);
  for (int i = 1; i <= n; i++)
    ans -= res[root[w[i]]], insert(root[w[i]], 1, n, i, pa[i], pb[i], 1),
        ans = (ans + 1ll * res[root[w[i]]] + 1000000007) % 1000000007;
  int q;
  scanf("%d", &q);
  while (q-- > 0) {
    int op, x;
    scanf("%d%d", &op, &x);
    if (op == 1)
      ans -= res[root[w[x]]], insert(root[w[x]], 1, n, x, 0, 0, 0),
          ans = (ans + 1ll * res[root[w[x]]] + 1000000007) % 1000000007;
    else
      ans -= res[root[w[x]]], insert(root[w[x]], 1, n, x, pa[x], pb[x], 1),
          ans = (ans + 1ll * res[root[w[x]]] + 1000000007) % 1000000007;
    printf("%d\n", ans);
  }
  return 0;
}
