#include <bits/stdc++.h>
using namespace std;
long long a, d[100002], g, h, j, k, l, n, m, pas, mod = 1000000007, y, t;
long long i, s;
map<long long, long long> q;
set<long long> w;
vector<vector<pair<long long, long long> > > v, v1;
struct tre {
  int val;
  tre *L;
  tre *R;
  tre() {
    val = 0;
    L = NULL;
    R = NULL;
  }
};
tre *root, *root1;
void add(tre *&it, long long l, long long r, long long idx) {
  if (l >= idx || r < idx) return;
  if (!it) it = new tre();
  it->val++;
  if (l + 1 == r) return;
  add(it->L, l, (l + r) / 2, idx);
  add(it->R, (l + r) / 2, r, idx);
}
long long fnd(tre *&it, long long l, long long r, long long idx) {
  if (!it) return 0;
  if (l > idx) return 0;
  if (r <= idx) return it->val;
  return fnd(it->L, l, (l + r) / 2, idx) + fnd(it->R, (l + r) / 2, r, idx);
}
struct tr {
  int ra;
  int la;
  long long Qra;
  int Qrd;
  long long Qla;
  long long Qshr;
  long long Qshl;
  tr *L;
  tr *R;
  tr() {
    ra = 0;
    la = 0;
    Qra = 0;
    Qrd = 0;
    Qla = 0;
    Qshr = 0;
    Qshl = 0;
    L = NULL;
    R = NULL;
  }
};
tr *rt[100002];
long long flag, rao;
void ad(tr *&it, long long l, long long r, long long idx, long long val) {
  if (l > idx || r <= idx) return;
  if (!it) it = new tr();
  if (flag) {
    it->ra += val;
  } else {
    it->la += val;
  }
  if (l + 1 == r) return;
  ad(it->L, l, (l + r) / 2, idx, val);
  ad(it->R, (l + r) / 2, r, idx, val);
}
void aD(tr *&it, long long l, long long r, long long idx, long long val) {
  if (l > idx || r <= idx) return;
  if (!it) it = new tr();
  if (flag) {
    it->ra += val;
  } else {
    it->la += val;
  }
  if (l + 1 == r) return;
  ad(it->L, l, (l + r) / 2, idx, val);
  ad(it->R, (l + r) / 2, r, idx, val);
}
long long sum(tr *&it, long long l, long long r, long long lf, long long rg) {
  if (!it) return 0;
  if (l >= rg || r <= lf) return 0;
  if (l >= lf && r <= rg) {
    return (lf ? it->ra : it->la);
  }
  return sum(it->L, l, (l + r) / 2, lf, rg) +
         sum(it->R, (l + r) / 2, r, lf, rg);
}
void shd(tr *&it) {
  if (it->L) {
    it->L->Qla += it->Qshl * (it->L->Qrd / 2);
    it->L->Qra += it->Qshr * (it->L->Qrd / 2);
    it->L->Qshl += it->Qshl;
    it->L->Qshr += it->Qshr;
  }
  if (it->R) {
    it->R->Qla += it->Qshl * (it->R->Qrd / 2);
    it->R->Qra += it->Qshr * (it->R->Qrd / 2);
    it->R->Qshl += it->Qshl;
    it->R->Qshr += it->Qshr;
  }
  it->Qshl = 0;
  it->Qshr = 0;
  return;
}
void ad1(tr *&it, long long l, long long r, long long lf, long long rg,
         long long val) {
  if (!it) {
    if (rao)
      it = new tr();
    else
      return;
  }
  if (l >= rg || r <= lf) return;
  if ((it->Qshl | it->Qshr)) shd(it);
  if (l >= lf && r <= rg) {
    if (flag) {
      if (rao)
        it->Qra += val;
      else {
        it->Qra += val * (it->Qrd / 2);
        it->Qshr += val;
      }
    } else {
      if (rao)
        it->Qla += val;
      else {
        it->Qla += val * (it->Qrd / 2);
        it->Qshl += val;
      }
    }
    it->Qrd += rao;
    return;
  }
  ad1(it->L, l, (l + r) / 2, lf, rg, val);
  ad1(it->R, (l + r) / 2, r, lf, rg, val);
  it->Qla = it->L->Qla + it->R->Qla;
  it->Qrd = it->L->Qrd + it->R->Qrd;
  it->Qra = it->L->Qra + it->R->Qra;
}
long long sum1(tr *&it, long long l, long long r, long long lf, long long rg) {
  if (!it) return 0;
  if (l >= rg || r <= lf) return 0;
  if (l >= lf && r <= rg) {
    return (lf ? it->Qra : it->Qla);
  }
  if ((it->Qshl | it->Qshr)) shd(it);
  return sum1(it->L, l, (l + r) / 2, lf, rg) +
         sum1(it->R, (l + r) / 2, r, lf, rg);
}
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    d[i] = a;
    w.insert(a);
  }
  v.push_back({});
  v1.push_back({});
  for (set<long long>::iterator it = w.begin(); it != w.end(); it++) {
    q[*it] = ++l;
    v.push_back({});
    v1.push_back({});
  }
  flag = 0;
  for (i = 0; i < n; i++) {
    d[i] = q[d[i]];
    k = fnd(root, 0, n, d[i]);
    v[d[i]].push_back({i, k});
    add(root, 0, n, d[i]);
    ad(rt[d[i]], 0, n, i, k);
  }
  flag = 1;
  rao = 1;
  for (i = n - 1; i >= 0; i--) {
    k = fnd(root1, 0, n, d[i]);
    v1[d[i]].push_back({-i, k});
    add(root1, 0, n, d[i]);
    ad(rt[d[i]], 0, n, i, k);
    long long le = sum(rt[d[i]], 0, n, 0, i);
    long long ri = sum(rt[d[i]], 0, n, i + 1, n);
    flag = 0;
    ad1(rt[d[i]], 0, n, i, i + 1, le);
    flag = 1;
    ad1(rt[d[i]], 0, n, i, i + 1, ri);
    pas = (pas + 1ll * le * ri) % mod;
  }
  rao = 0;
  if (h) return 0;
  cin >> m;
  for (i = 0; i < m; i++) {
    rao = 0;
    scanf("%d%d", &a, &s);
    s--;
    if (a == 2) {
      l = d[s];
      k = lower_bound(v[l].begin(), v[l].end(), make_pair(s, 0ll))->second;
      j = lower_bound(v1[l].begin(), v1[l].end(), make_pair(-s, 0ll))->second;
      long long p1 = sum(rt[l], 0, n, s + 1, n);
      long long p2 = sum(rt[l], 0, n, 0, s);
      pas = (pas + 1ll * p1 * p2) % mod;
      pas = (pas + 1ll * sum1(rt[l], 0, n, s + 1, n) * k) % mod;
      pas = (pas + 1ll * j * sum1(rt[l], 0, n, 0, s)) % mod;
      flag = 0;
      ad1(rt[l], 0, n, s + 1, n, k);
      rao = 1;
      ad1(rt[l], 0, n, s, s + 1, p2);
      rao = 0;
      flag = 1;
      ad1(rt[l], 0, n, 0, s, j);
      rao = 1;
      ad1(rt[l], 0, n, s, s + 1, p1);
      rao = 0;
      flag = 0;
      ad(rt[l], 0, n, s, k);
      flag = 1;
      ad(rt[l], 0, n, s, j);
    } else {
      l = d[s];
      k = lower_bound(v[l].begin(), v[l].end(), make_pair(s, 0ll))->second;
      j = lower_bound(v1[l].begin(), v1[l].end(), make_pair(-s, 0ll))->second;
      long long p1 = sum(rt[l], 0, n, s + 1, n);
      long long p2 = sum(rt[l], 0, n, 0, s);
      pas = (pas - 1ll * p1 * p2 % mod + mod) % mod;
      pas = (pas - 1ll * sum1(rt[l], 0, n, s + 1, n) * k % mod + mod) % mod;
      pas = (pas - 1ll * j * sum1(rt[l], 0, n, 0, s) % mod + mod) % mod;
      flag = 0;
      ad1(rt[l], 0, n, s + 1, n, -k);
      rao = -1;
      ad1(rt[l], 0, n, s, s + 1, -p2);
      rao = 0;
      flag = 1;
      ad1(rt[l], 0, n, 0, s, -j);
      rao = -1;
      ad1(rt[l], 0, n, s, s + 1, -p1);
      rao = 0;
      flag = 0;
      ad(rt[l], 0, n, s, -k);
      flag = 1;
      ad(rt[l], 0, n, s, -j);
    }
    cout << pas << endl;
  }
}
