#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
template <class T>
using V = vector<T>;
template <class T>
using VV = vector<vector<T>>;
template <class T, class U>
void chmax(T& x, U y) {
  if (x < y) x = y;
}
template <class T, class U>
void chmin(T& x, U y) {
  if (y < x) x = y;
}
template <class T>
void mkuni(V<T>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
template <class T>
int lwb(const V<T>& v, const T& x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p) {
  return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc) {
  o << "{";
  for (const T& v : vc) o << v << ",";
  o << "}";
  return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <unsigned int mod_>
struct ModInt {
  using uint = unsigned int;
  using ll = long long;
  using ull = unsigned long long;
  constexpr static uint mod = mod_;
  uint v;
  ModInt() : v(0) {}
  ModInt(ll _v) : v(normS(_v % mod + mod)) {}
  explicit operator bool() const { return v != 0; }
  static uint normS(const uint& x) { return (x < mod) ? x : x - mod; }
  static ModInt make(const uint& x) {
    ModInt m;
    m.v = x;
    return m;
  }
  ModInt operator+(const ModInt& b) const { return make(normS(v + b.v)); }
  ModInt operator-(const ModInt& b) const { return make(normS(v + mod - b.v)); }
  ModInt operator-() const { return make(normS(mod - v)); }
  ModInt operator*(const ModInt& b) const { return make((ull)v * b.v % mod); }
  ModInt operator/(const ModInt& b) const { return *this * b.inv(); }
  ModInt& operator+=(const ModInt& b) { return *this = *this + b; }
  ModInt& operator-=(const ModInt& b) { return *this = *this - b; }
  ModInt& operator*=(const ModInt& b) { return *this = *this * b; }
  ModInt& operator/=(const ModInt& b) { return *this = *this / b; }
  ModInt& operator++(int) { return *this = *this + 1; }
  ModInt& operator--(int) { return *this = *this - 1; }
  ll extgcd(ll a, ll b, ll& x, ll& y) const {
    ll p[] = {a, 1, 0}, q[] = {b, 0, 1};
    while (*q) {
      ll t = *p / *q;
      for (int i = 0; i < int(3); i++) swap(p[i] -= t * q[i], q[i]);
    }
    if (p[0] < 0)
      for (int i = 0; i < int(3); i++) p[i] = -p[i];
    x = p[1], y = p[2];
    return p[0];
  }
  ModInt inv() const {
    ll x, y;
    extgcd(v, mod, x, y);
    return make(normS(x + mod));
  }
  ModInt pow(ll p) const {
    if (p < 0) return inv().pow(-p);
    ModInt a = 1;
    ModInt x = *this;
    while (p) {
      if (p & 1) a *= x;
      x *= x;
      p >>= 1;
    }
    return a;
  }
  bool operator==(const ModInt& b) const { return v == b.v; }
  bool operator!=(const ModInt& b) const { return v != b.v; }
  friend istream& operator>>(istream& o, ModInt& x) {
    ll tmp;
    o >> tmp;
    x = ModInt(tmp);
    return o;
  }
  friend ostream& operator<<(ostream& o, const ModInt& x) { return o << x.v; }
};
using mint = ModInt<1000000007>;
template <class D>
struct segtree {
  int N;
  vector<D> val;
  segtree() {}
  segtree(int n) {
    N = 1;
    while (N < n) N *= 2;
    val.assign(N * 2, D::e());
  }
  segtree(const vector<D>& ds) {
    int n = ds.size();
    N = 1;
    while (N < n) N *= 2;
    val.assign(N * 2, D::e());
    for (int i = 0; i < int(n); i++) val[i + N] = ds[i];
    for (int i = N - 1; i > 0; i--) val[i] = val[i * 2] + val[i * 2 + 1];
  }
  void assign(int k, D d) {
    k += N;
    val[k] = d;
    k /= 2;
    while (k) {
      val[k] = val[k * 2] + val[k * 2 + 1];
      k /= 2;
    }
  }
  D query(int a, int b) {
    D L = D::e(), R = D::e();
    a += N, b += N;
    while (a < b) {
      if (a & 1) L = L + val[a++];
      if (b & 1) R = val[--b] + R;
      a /= 2, b /= 2;
    }
    return L + R;
  }
};
struct D {
  mint l, lo, lor, o, OR, r;
  D() {}
  D(int l_, int r_) : l(l_), o(1), r(r_) {}
  static D e() { return D(); }
};
D operator+(const D& x, const D& y) {
  D z;
  z.l = x.l + y.l;
  z.lo = x.lo + x.l * y.o + y.lo;
  z.lor = x.lor + x.lo * y.r + x.l * y.OR + y.lor;
  z.o = x.o + y.o;
  z.OR = x.OR + x.o * y.r + y.OR;
  z.r = x.r + y.r;
  return z;
}
struct BIT {
  using D = int;
  int N;
  vector<D> bit;
  BIT(int n) {
    N = n;
    bit.assign(n + 1, 0);
  }
  BIT() {}
  void init(int n) {
    N = n;
    bit.assign(n + 1, 0);
  }
  D sum(int i) {
    D s = 0;
    while (i > 0) {
      s += bit[i];
      i -= (i & -i);
    }
    return s;
  }
  D val(int i) { return sum(i + 1) - sum(i); }
  void add(int i, D x) {
    i++;
    while (i <= N) {
      bit[i] += x;
      i += (i & -i);
    }
  }
  void assign(int i, D x) { add(i, x - val(i)); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  V<int> A(N);
  for (int i = 0; i < int(N); i++) cin >> A[i];
  V<int> vs = A;
  mkuni(vs);
  for (int i = 0; i < int(N); i++) A[i] = lwb(vs, A[i]);
  int K = int(vs.size());
  V<int> cnt(K);
  V<int> idx(N);
  for (int i = 0; i < int(N); i++) {
    idx[i] = cnt[A[i]]++;
  }
  V<int> L(N), R(N);
  {
    BIT bit(K);
    for (int i = 0; i < int(N); i++) {
      L[i] = bit.sum(A[i] + 1);
      bit.add(A[i], 1);
    }
    bit = BIT(K);
    for (int i = int(N) - 1; i >= 0; i--) {
      R[i] = bit.sum(A[i] + 1);
      bit.add(A[i], 1);
    }
  }
  void(0);
  void(0);
  V<segtree<D>> ss(K);
  for (int i = 0; i < int(K); i++) ss[i] = segtree<D>(cnt[i]);
  for (int i = 0; i < int(N); i++) {
    ss[A[i]].assign(idx[i], D(L[i], R[i]));
  }
  int Q;
  cin >> Q;
  mint ans = 0;
  for (int v = 0; v < int(K); v++) ans += ss[v].query(0, cnt[v]).lor;
  while (Q--) {
    int t, i;
    cin >> t >> i;
    i--;
    ans -= ss[A[i]].query(0, cnt[A[i]]).lor;
    if (t == 1) {
      ss[A[i]].assign(idx[i], D());
    } else {
      ss[A[i]].assign(idx[i], D(L[i], R[i]));
    }
    ans += ss[A[i]].query(0, cnt[A[i]]).lor;
    cout << ans << '\n';
  }
}
