#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, P = 1e9 + 7;
int c[maxn], pre[maxn], suc[maxn], n, m, opt, a[maxn], b[maxn], k, w;
long long ans;
struct Node {
  Node *lc, *rc;
  long long A, B, C, AB, BC, ABC;
  void maintain() {
    A = (lc->A + rc->A) % P;
    B = (lc->B + rc->B) % P;
    C = (lc->C + rc->C) % P;
    AB = (lc->AB + rc->AB + lc->A * rc->B % P) % P;
    BC = (lc->BC + rc->BC + lc->B * rc->C % P) % P;
    ABC = (lc->ABC + rc->ABC + lc->AB * rc->C % P + lc->A * rc->BC % P) % P;
  }
} * null, pool[maxn * 20], *rt[maxn];
void add(int i, int x) {
  for (; i <= w; i += i & (-i)) c[i] += x;
}
int sum(int i) {
  int ans = 0;
  for (; i; i -= i & (-i)) ans += c[i];
  return ans;
}
Node* newnode() {
  static int cnt = 0;
  pool[cnt] = (Node){null, null, 0, 0, 0, 0, 0, 0};
  return &pool[cnt++];
}
void upd(Node*& cur, int l, int r, int x, int y) {
  if (cur == null) cur = newnode();
  if (l == r) {
    cur->A = pre[x] * y;
    cur->B = y;
    cur->C = suc[x] * y;
    return;
  }
  int mid = (l + r) >> 1;
  if (x > mid)
    upd(cur->rc, mid + 1, r, x, y);
  else
    upd(cur->lc, l, mid, x, y);
  cur->maintain();
}
int main() {
  null = new Node;
  null->lc = null->rc = null;
  null->A = null->B = null->C = null->AB = null->BC = null->ABC = 0;
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]), b[i] = a[i];
  sort(a + 1, a + n + 1);
  w = unique(a + 1, a + n + 1) - a - 1;
  for (int i = (1); i <= (n); ++i)
    b[i] = lower_bound(a + 1, a + w + 1, b[i]) - a;
  for (int i = (1); i <= (n); ++i) pre[i] = sum(b[i]), add(b[i], 1);
  memset(c, 0, sizeof(c));
  for (int i = (n); i >= (1); --i) suc[i] = sum(b[i]), add(b[i], 1);
  for (int i = (1); i <= (w); ++i) rt[i] = null;
  for (int i = (1); i <= (n); ++i)
    ans = (ans - rt[b[i]]->ABC + P) % P, upd(rt[b[i]], 1, n, i, 1),
    ans = (ans + rt[b[i]]->ABC) % P;
  scanf("%d", &m);
  for (int i = (1); i <= (m); ++i) {
    scanf("%d%d", &opt, &k);
    ans = (ans - rt[b[k]]->ABC + P) % P;
    upd(rt[b[k]], 1, n, k, opt - 1);
    ans = (ans + rt[b[k]]->ABC) % P;
    printf("%d\n", (int)ans);
  }
  return 0;
}
