#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  if (p1 == p2) {
    p2 = (p1 = buf) + fread(buf, 1, 100000, stdin);
    if (p1 == p2) return EOF;
  }
  return *p1++;
}
inline void Read(int& x) {
  char c = nc();
  for (; c < '0' || c > '9'; c = nc())
    ;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - 48, c = nc())
    ;
}
int Len;
char ss[30];
inline void Print(int x) {
  if (!x) {
    putchar(48);
    putchar('\n');
    return;
  }
  for (Len = 0; x; x /= 10) ss[++Len] = x % 10;
  while (Len) putchar(ss[Len--] + 48);
  putchar('\n');
}
struct Node {
  int l, r, w[5], p[2];
} c[100010 << 2];
struct Disc {
  int w, f;
} d[100010];
vector<int> g[100010];
int i, j, k, n, m, a[100010], s1[100010], s2[100010], b[100010], Num,
    Rt[100010], f[100010], s[100010], Ans, Q, x, y, S, t;
inline bool Cmp(Disc a, Disc b) { return a.w < b.w; }
inline void Update1(int x) {
  for (; x <= m; x += x & -x) b[x]++;
}
inline int Query1(int x) {
  int Ans = 0;
  for (; x; x -= x & -x) Ans += b[x];
  return Ans;
}
inline void Update_sum(int x, int y, int d) {
  c[x].w[d + 2] =
      (c[x].w[d + 2] + 1ll * y * c[x].w[d] % 1000000007) % 1000000007;
  c[x].p[d] += y;
}
inline void Up(int x) {
  for (int i = 0; i < 5; i++)
    c[x].w[i] = (c[c[x].l].w[i] + c[c[x].r].w[i]) % 1000000007;
}
inline void Down(int x) {
  for (int i = 1; i >= 0; i--)
    if (c[x].p[i]) {
      Update_sum(c[x].l, c[x].p[i], i);
      Update_sum(c[x].r, c[x].p[i], i);
      c[x].p[i] = 0;
    }
}
inline int Query(int x, int l, int r, int L, int R, int d) {
  if (l >= L && r <= R) return c[x].w[d];
  Down(x);
  int Mid = l + r >> 1;
  if (Mid < L) return Query(c[x].r, Mid + 1, r, L, R, d);
  if (Mid >= R) return Query(c[x].l, l, Mid, L, R, d);
  return (Query(c[x].l, l, Mid, L, R, d) + Query(c[x].r, Mid + 1, r, L, R, d)) %
         1000000007;
}
inline void Build(int& x, int l, int r, int y) {
  x = ++Num;
  if (l == r) {
    int a = s1[g[y][l - 1]], b = s2[g[y][l - 1]];
    c[x].w[0] = a;
    c[x].w[1] = b;
    c[x].w[2] = 1ll * a * (s[y] - l + 1) % 1000000007;
    c[x].w[3] = 1ll * b * l % 1000000007;
    c[x].w[4] = 1;
    return;
  }
  int Mid = l + r >> 1;
  Build(c[x].l, l, Mid, y);
  Build(c[x].r, Mid + 1, r, y);
  Up(x);
}
inline void Update1(int x, int l, int r, int p, int y, int d) {
  if (l == r) {
    if (d == 1) {
      int a = s1[g[y][l - 1]], b = s2[g[y][l - 1]];
      c[x].w[0] = a;
      c[x].w[1] = b;
      if (l < s[y])
        c[x].w[2] =
            1ll * a * (Query(Rt[y], 1, s[y], l + 1, s[y], 4) + 1) % 1000000007;
      else
        c[x].w[3] = a;
      if (l > 1)
        c[x].w[3] =
            1ll * b * (Query(Rt[y], 1, s[y], 1, l - 1, 4) + 1) % 1000000007;
      else
        c[x].w[3] = b;
      c[x].w[4] = 1;
    } else
      memset(c[x].w, 0, sizeof(c[x].w));
    return;
  }
  Down(x);
  int Mid = l + r >> 1;
  if (p <= Mid)
    Update1(c[x].l, l, Mid, p, y, d);
  else
    Update1(c[x].r, Mid + 1, r, p, y, d);
  Up(x);
}
inline void Update(int x, int l, int r, int L, int R, int d, bool t) {
  if (l >= L && r <= R) {
    Update_sum(x, d, t);
    return;
  }
  Down(x);
  int Mid = l + r >> 1;
  if (Mid >= L) Update(c[x].l, l, Mid, L, R, d, t);
  if (Mid < R) Update(c[x].r, Mid + 1, r, L, R, d, t);
  Up(x);
}
inline void Find1(int x, int l, int r, int L, int R) {
  if (S >= 2) return;
  if (l == r) {
    S += c[x].w[4];
    if (S == 2) t = l;
    return;
  }
  Down(x);
  if (l >= L && r <= R) {
    int Mid = l + r >> 1;
    if (S + c[c[x].l].w[4] >= 2)
      Find1(c[x].l, l, Mid, L, R);
    else if (S + c[x].w[4] >= 2)
      S += c[c[x].l].w[4], Find1(c[x].r, Mid + 1, r, L, R);
    else
      S += c[x].w[4];
    return;
  }
  int Mid = l + r >> 1;
  if (Mid >= L) Find1(c[x].l, l, Mid, L, R);
  if (Mid < R) Find1(c[x].r, Mid + 1, r, L, R);
}
inline void Find2(int x, int l, int r, int L, int R) {
  if (S >= 2) return;
  if (l == r) {
    S += c[x].w[4];
    if (S == 2) t = l;
    return;
  }
  Down(x);
  if (l >= L && r <= R) {
    int Mid = l + r >> 1;
    if (S + c[c[x].r].w[4] >= 2)
      Find2(c[x].r, Mid + 1, r, L, R);
    else if (S + c[x].w[4] >= 2)
      S += c[c[x].r].w[4], Find2(c[x].l, l, Mid, L, R);
    else
      S += c[x].w[4];
    return;
  }
  int Mid = l + r >> 1;
  if (Mid < R) Find2(c[x].r, Mid + 1, r, L, R);
  if (Mid >= L) Find2(c[x].l, l, Mid, L, R);
}
inline void Update_seq(int x, int d) {
  if (f[x] > 1 && f[x] < s[a[x]])
    Ans = (Ans + 1ll * d * Query(Rt[a[x]], 1, s[a[x]], 1, f[x] - 1, 0) *
                     Query(Rt[a[x]], 1, s[a[x]], f[x] + 1, s[a[x]], 1) %
                     1000000007) %
          1000000007;
  if (f[x] < s[a[x]]) {
    S = t = 0;
    Find1(Rt[a[x]], 1, s[a[x]], f[x] + 1, s[a[x]]);
    if (t)
      Ans = (Ans +
             1ll * d * s1[x] *
                 (Query(Rt[a[x]], 1, s[a[x]], t, s[a[x]], 3) -
                  1ll * Query(Rt[a[x]], 1, s[a[x]], 1, t - 1, 4) *
                      Query(Rt[a[x]], 1, s[a[x]], t, s[a[x]], 1) % 1000000007) %
                 1000000007) %
            1000000007;
    Update(Rt[a[x]], 1, s[a[x]], f[x] + 1, s[a[x]], d, 1);
  }
  if (f[x] > 1) {
    S = t = 0;
    Find2(Rt[a[x]], 1, s[a[x]], 1, f[x] - 1);
    if (t)
      Ans = (Ans + 1ll * d * s2[x] *
                       (Query(Rt[a[x]], 1, s[a[x]], 1, t, 2) -
                        1ll * Query(Rt[a[x]], 1, s[a[x]], t + 1, s[a[x]], 4) *
                            Query(Rt[a[x]], 1, s[a[x]], 1, t, 0) % 1000000007) %
                       1000000007) %
            1000000007;
    Update(Rt[a[x]], 1, s[a[x]], 1, f[x] - 1, d, 0);
  }
  Update1(Rt[a[x]], 1, s[a[x]], f[x], a[x], d);
}
int main() {
  Read(n);
  for (i = 1; i <= n; i++) Read(d[i].w), d[i].f = i;
  sort(d + 1, d + n + 1, Cmp);
  a[d[1].f] = m = 1;
  for (i = 2; i <= n; i++)
    if (d[i].w == d[i - 1].w)
      a[d[i].f] = m;
    else
      a[d[i].f] = ++m;
  for (i = 1; i <= n; i++) {
    g[a[i]].push_back(i);
    f[i] = g[a[i]].size();
    s1[i] = Query1(a[i]);
    Update1(a[i]);
  }
  memset(b, 0, sizeof(b));
  for (i = n; i; i--) {
    s2[i] = Query1(a[i]);
    Update1(a[i]);
  }
  for (i = 1; i <= m; i++) s[i] = g[i].size(), Build(Rt[i], 1, s[i], i);
  for (i = 1; i <= n; i++)
    if (f[i] > 1 && f[i] < s[a[i]])
      Ans = (Ans + 1ll * Query(Rt[a[i]], 1, s[a[i]], 1, f[i] - 1, 0) *
                       Query(Rt[a[i]], 1, s[a[i]], f[i] + 1, s[a[i]], 1) %
                       1000000007) %
            1000000007;
  Read(Q);
  while (Q--) {
    Read(k);
    Read(x);
    Update_seq(x, k == 1 ? -1 : 1);
    Print((Ans + 1000000007) % 1000000007);
  }
  return 0;
}
