#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 1000, K = 60;
const int INF = 1e9;
const int MAGIC = 50;
int a[N];
int b[N / MAGIC][K + 1];
int c[N];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  for (int i = 0; i < N; i++) {
    c[i] = i / MAGIC;
    a[i] = INF;
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N / MAGIC; i++) {
    for (int j = 0; j <= K; j++) {
      b[i][j] = j;
    }
  }
  auto go = [&](int &x, int y) {
    if (x % y == 0) x++;
    x++;
  };
  auto upd = [&](int pos) {
    for (int j = 0; j <= K; j++) {
      b[pos][j] = j;
    }
    for (int i = pos * MAGIC; i < (pos + 1) * MAGIC; i++) {
      for (int j = 0; j <= K; j++) {
        go(b[c[i]][j], a[i]);
      }
    }
  };
  for (int i = 0; i < N / MAGIC; i++) upd(i);
  int q;
  cin >> q;
  while (q--) {
    char type;
    cin >> type;
    if (type == 'A') {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      r--;
      int ans = 0;
      while (l <= r) {
        if (l % MAGIC == 0 && l + MAGIC - 1 <= r) {
          int rem = ans % K;
          ans += b[c[l]][rem] - rem;
          l += MAGIC;
        } else {
          go(ans, a[l]);
          l++;
        }
      }
      cout << ans << '\n';
    } else {
      int pos, x;
      cin >> pos >> x;
      pos--;
      a[pos] = x;
      upd(c[pos]);
    }
  }
}
