#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int v[60][4 * MAXN];
int ar[MAXN];
void build(int node, int start, int end) {
  if (start == end) {
    for (int j = 0; j < 60; j++) v[j][node] = 0;
    return;
  }
  int mid = (start + end) >> 1;
  build(2 * node, start, mid);
  build(2 * node + 1, mid + 1, end);
  for (int j = 0; j < 60; j++) {
    int t = v[j][2 * node];
    int mv = j + t;
    mv %= 60;
    for (; mv % ar[mid] == 0; t++, mv = (mv + 1) % 60)
      ;
    t++;
    mv = (mv + 1) % 60;
    t += v[mv][2 * node + 1];
    v[j][node] = t;
  }
}
void update(int node, int start, int end, int qs) {
  if (start > end or qs < start or qs > end) return;
  if (start >= qs and end <= qs) return;
  int mid = (start + end) >> 1;
  update(2 * node, start, mid, qs);
  update(2 * node + 1, mid + 1, end, qs);
  for (int j = 0; j < 60; j++) {
    int t = v[j][2 * node];
    int mv = j + t;
    mv %= 60;
    for (; mv % ar[mid] == 0; t++, mv = (mv + 1) % 60)
      ;
    t++;
    mv = (mv + 1) % 60;
    t += v[mv][2 * node + 1];
    v[j][node] = t;
  }
}
int ans, previ;
void query(int node, int start, int end, int qs, int qe) {
  if (start > end or qe < start or qs > end) return;
  if (start >= qs and end <= qe) {
    if (previ == -1)
      ans = v[0][node];
    else {
      for (; ans % ar[previ] == 0; ans++)
        ;
      ans++;
      ans += v[ans % 60][node];
    }
    previ = end;
    return;
  }
  int mid = (start + end) >> 1;
  query(2 * node, start, mid, qs, qe);
  query(2 * node + 1, mid + 1, end, qs, qe);
}
void reset() {
  ans = 0;
  previ = -1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
  int q;
  cin >> q;
  build(1, 1, n + 1);
  while (q--) {
    char ch;
    int x, y;
    scanf(" %c%d%d", &ch, &x, &y);
    if (ch == 'C') {
      ar[x] = y;
      update(1, 1, n + 1, x);
    } else {
      reset();
      query(1, 1, n + 1, x, y);
      printf("%d\n", ans);
    }
  }
  return 0;
}
