#include <bits/stdc++.h>
using namespace std;
const int maxn = 500010, inf = 1e9, mod = 1e9 + 7;
struct poi {
  int czl[3][3], l, r;
} tree[maxn * 8];
int n, c, m, x, y, z, tot, len;
long long ans;
int a[maxn], b[maxn], sz[maxn], zb[maxn], yb[maxn], root[maxn];
void read(int &k) {
  int f = 1;
  k = 0;
  char c = getchar();
  while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
  while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
  k *= f;
}
int lowbit(int x) { return x & -x; }
void add(int x, int y) {
  for (; x <= c; x += lowbit(x)) sz[x] += y;
}
int find(int x) {
  int sum = 0;
  for (; x; x -= lowbit(x)) sum += sz[x];
  return sum;
}
void update(int x) {
  int l = tree[x].l, r = tree[x].r;
  tree[x].czl[0][0] = tree[l].czl[0][0] + tree[r].czl[0][0];
  tree[x].czl[1][1] = tree[l].czl[1][1] + tree[r].czl[1][1];
  tree[x].czl[2][2] = tree[l].czl[2][2] + tree[r].czl[2][2];
  tree[x].czl[0][1] = (tree[l].czl[0][1] + tree[r].czl[0][1] +
                       1ll * tree[l].czl[0][0] * tree[r].czl[1][1]) %
                      mod;
  tree[x].czl[1][2] = (tree[l].czl[1][2] + tree[r].czl[1][2] +
                       1ll * tree[l].czl[1][1] * tree[r].czl[2][2]) %
                      mod;
  tree[x].czl[0][2] = (tree[l].czl[0][2] + tree[r].czl[0][2] +
                       1ll * tree[l].czl[0][1] * tree[r].czl[2][2] +
                       1ll * tree[l].czl[0][0] * tree[r].czl[1][2]) %
                      mod;
}
void gs(int x, int l, int r, int delta, int ty) {
  if (l == r) {
    if (ty == 1)
      tree[x].czl[0][0] = tree[x].czl[1][1] = tree[x].czl[2][2] = 0;
    else
      tree[x].czl[0][0] = zb[delta], tree[x].czl[1][1] = 1,
      tree[x].czl[2][2] = yb[delta];
    return;
  }
  int mid = (l + r) >> 1;
  if (mid >= delta) {
    if (!tree[x].l) tree[x].l = ++tot;
    gs(tree[x].l, l, mid, delta, ty);
  }
  if (mid < delta) {
    if (!tree[x].r) tree[x].r = ++tot;
    gs(tree[x].r, mid + 1, r, delta, ty);
  }
  update(x);
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]), b[i] = a[i];
  sort(b + 1, b + 1 + n);
  c = unique(b + 1, b + 1 + n) - b - 1;
  for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, b + 1 + c, a[i]) - b;
  for (int i = 1; i <= n; i++) zb[i] = find(a[i]), add(a[i], 1);
  memset(sz, 0, sizeof(sz));
  for (int i = n; i; i--) yb[i] = find(a[i]), add(a[i], 1);
  for (int i = 1; i <= n; i++) {
    if (!root[a[i]]) root[a[i]] = ++tot;
    gs(root[a[i]], 1, n, i, 2);
  };
  for (int i = 1; i <= c; i++)
    ans = (ans + tree[root[i]].czl[0][2]) % mod,
    ans = ans >= mod ? ans - mod : ans;
  read(m);
  for (int i = 1; i <= m; i++) {
    read(x);
    read(y);
    ans = (ans - (long long)tree[root[a[y]]].czl[0][2] + mod);
    if (ans >= mod) ans -= mod;
    if (x == 2)
      gs(root[a[y]], 1, n, y, 2);
    else
      gs(root[a[y]], 1, n, y, 1);
    ans = (ans + (long long)tree[root[a[y]]].czl[0][2]);
    if (ans >= mod) ans -= mod;
    printf("%I64d\n", ans);
  }
  return 0;
}
