#include <bits/stdc++.h>
using namespace std;
const pair<int, int> DD[] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                             {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
template <class T>
T smin(T &a, T b) {
  if (a > b) a = b;
  return a;
}
template <class T>
T smax(T &a, T b) {
  if (a < b) a = b;
  return a;
}
struct mat {
  int D[4][4];
  mat(void) { memset(D, 0, sizeof(D)); }
};
const int mod = 1e9 + 7;
mat T[1 << 20];
int Root[1 << 20];
int L[1 << 20];
int R[1 << 20];
int SZ = 0;
mat operator+(mat a, mat b) {
  mat c;
  for (int k = 0; k < 4; ++k)
    for (int i = 0; i < 4; ++i)
      for (int j = 0; j < 4; ++j)
        c.D[i][j] = (c.D[i][j] + 1ll * a.D[i][k] * b.D[k][j]) % mod;
  return c;
}
int get(int &k) {
  if (!k) k = ++SZ;
  return k;
}
int D1[1 << 20];
int D2[1 << 20];
int t[1 << 20];
int s[1 << 20];
vector<int> N[1 << 20];
void build(int p, int u, int init, int node) {
  if (p == u) {
    for (int i = 0; i < 4; ++i) T[node].D[i][i] = 1;
    T[node].D[0][1] = D1[N[init][p - 1]];
    T[node].D[1][2] = 1;
    T[node].D[2][3] = D2[N[init][p - 1]];
  } else {
    int m = (p + u) / 2;
    build(p, m, init, get(L[node]));
    build(m + 1, u, init, get(R[node]));
    T[node] = T[get(L[node])] + T[get(R[node])];
  }
}
void update(int p, int u, int pos, int how, int init, int node) {
  if (p == u) {
    memset(T[node].D, 0, sizeof(T[node].D));
    for (int i = 0; i < 4; ++i) T[node].D[i][i] = 1;
    if (how) {
      T[node].D[0][1] = D1[N[init][p - 1]];
      T[node].D[1][2] = 1;
      T[node].D[2][3] = D2[N[init][p - 1]];
    }
  } else {
    int m = (p + u) / 2;
    if (pos <= m)
      update(p, m, pos, how, init, get(L[node]));
    else
      update(m + 1, u, pos, how, init, get(R[node]));
    T[node] = T[get(L[node])] + T[get(R[node])];
  }
}
int main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  vector<int> ss;
  int n;
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s[i], ss.push_back(s[i]);
  sort(ss.begin(), ss.end());
  ss.resize(unique(ss.begin(), ss.end()) - ss.begin());
  int sz = ss.size();
  for (int i = 1; i <= n; ++i)
    s[i] = lower_bound(ss.begin(), ss.end(), s[i]) - ss.begin() + 1;
  auto Query = [&](int i) {
    int ans = 0;
    for (; i; i -= i & (-i)) ans += t[i];
    return ans;
  };
  auto Update = [&](int i) {
    for (; i <= sz; i += i & (-i)) ++t[i];
  };
  static int POS[1 << 20];
  for (int i = 1; i <= n; ++i) D1[i] = Query(s[i]), Update(s[i]);
  for (int i = 1; i <= sz; ++i) t[i] = 0;
  for (int i = n; i; --i) D2[i] = Query(s[i]), Update(s[i]);
  for (int i = 1; i <= n; ++i) N[s[i]].push_back(i), POS[i] = N[s[i]].size();
  int ans = 0;
  for (int i = 1; i <= sz; ++i)
    build(1, N[i].size(), i, get(Root[i])),
        (ans += T[get(Root[i])].D[0][3]) %= mod;
  int m;
  cin >> m;
  while (m--) {
    int op;
    int pos;
    cin >> op >> pos;
    (ans += mod - T[get(Root[s[pos]])].D[0][3]) %= mod;
    update(1, N[s[pos]].size(), POS[pos], op - 1, s[pos], get(Root[s[pos]]));
    (ans += T[get(Root[s[pos]])].D[0][3]) %= mod;
    cout << ans << '\n';
  }
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
