#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const int M = 1e9 + 7;
const int N = 100100;
int a[N];
int pre[N], suf[N];
int BIT[N];
int sum(int x) {
  int r = 0;
  while (x > 0) {
    r += BIT[x];
    x -= (x & -x);
  }
  return r;
}
void update(int x, int v) {
  while (x < N) {
    BIT[x] += v;
    x += (x & -x);
  }
}
inline int sum(int a, int b) {
  int c = (a + b);
  if (c >= M) c -= M;
  return c;
}
inline int prod(int a, int b) { return (a * 1LL * b) % M; }
vector<int> vec[N];
int SZ = 4;
struct node {
  vector<int> x;
  node operator+(const node& rhs) const {
    node r;
    r.x = vector<int>(16, 0);
    for (int i = 0; i < (4); ++i) {
      for (int j = 0; j < (4); ++j) {
        for (int k = 0; k < (4); ++k) {
          r.x[4 * i + j] =
              sum(r.x[4 * i + j], prod(x[4 * i + k], rhs.x[4 * k + j]));
        }
      }
    }
    return r;
  }
};
template <class T>
struct ST {
  vector<T> st;
  int n;
  T ini;
  ST() {}
  ST(int n, T ini) : st(2 * n, ini), n(n), ini(ini) {}
  void upd(int pos, T val) {
    for (st[pos += n] = val; pos /= 2;) st[pos] = st[2 * pos] + st[2 * pos + 1];
  }
  T query(int x, int y) {
    T ra = ini, rb = ini;
    for (x += n, y += n + 1; x < y; x /= 2, y /= 2) {
      if (x & 1) ra = ra + st[x], x++;
      if (y & 1) --y, rb = st[y] + rb;
    }
    return ra + rb;
  }
};
vector<int> def(16, 0);
node make(int id, int good) {
  vector<int> mat = def;
  if (!good) return {mat};
  mat[0 * 4 + 1] = pre[id];
  mat[1 * 4 + 2] = 1;
  mat[2 * 4 + 3] = suf[id];
  return {mat};
}
int good[N];
int pos[N];
ST<node> T[N];
int cur[N];
int32_t main() {
  def[0] = def[5] = def[10] = def[15] = 1;
  int n;
  scanf("%d", &n);
  vector<int> comp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    good[i] = 1;
    comp.push_back(a[i]);
  }
  sort(comp.begin(), comp.end());
  comp.erase(unique(comp.begin(), comp.end()), comp.end());
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(comp.begin(), comp.end(), a[i]) - comp.begin() + 1;
  }
  for (int i = 1; i <= n; i++) {
    pre[i] = sum(a[i]);
    update(a[i], 1);
    vec[a[i]].push_back(i);
  }
  for (int j = 0; j < N; j++) BIT[j] = 0;
  for (int i = n; i >= 1; i--) {
    suf[i] = sum(a[i]);
    update(a[i], 1);
  }
  node ini = {def};
  long long ans = 0;
  for (int i = 1; i <= (int)comp.size(); i++) {
    int tam = (int)vec[i].size();
    T[i] = ST<node>(tam, ini);
    int p = 0;
    for (int x : vec[i]) {
      T[i].upd(p, make(x, good[x]));
      pos[x] = p++;
    }
    cur[i] = T[i].query(0, p - 1).x[3];
    ans = (ans + cur[i]);
    if (ans >= M) ans -= M;
  }
  int m;
  scanf("%d", &m);
  while (m--) {
    int t, v;
    scanf("%d%d", &t, &v);
    good[v] ^= 1;
    ans = (ans - cur[a[v]]);
    if (ans < 0) ans += M;
    T[a[v]].upd(pos[v], make(v, good[v]));
    cur[a[v]] = T[a[v]].query(0, (int)vec[a[v]].size() - 1).x[3];
    ans = (ans + cur[a[v]]);
    if (ans >= M) ans -= M;
    if (ans < 0) ans += M;
    printf("%lld\n", ans);
  }
}
