#include <bits/stdc++.h>
using namespace std;
const int TAM = 1e5 + 10;
struct node {
  int val[61];
  long long calc;
  int from, to;
};
node ST[TAM * 4];
int arr[TAM];
void make_tree(int pos, int from, int to) {
  node &x = ST[pos];
  x.from = from;
  x.to = to;
  x.calc = 0ll;
  if (from == to) {
    return;
  }
  int mid = (from + to) / 2;
  make_tree((pos * 2), from, mid);
  make_tree((pos * 2 + 1), mid + 1, to);
}
void change(int pos, int dest, int val) {
  node &x = ST[pos];
  x.calc = 0ll;
  if (x.from == x.to && x.from == dest) {
    arr[x.from] = val;
    return;
  }
  if (dest <= ST[(pos * 2)].to)
    change((pos * 2), dest, val);
  else
    change((pos * 2 + 1), dest, val);
}
int calc(int pos, int from, int to, int st) {
  node &x = ST[pos];
  if (x.from == x.to) return st + 1 + ((st % arr[x.from]) == 0);
  if (x.from == from && x.to == to && (x.calc & (1ll << st)) != 0)
    return x.val[st];
  if (to <= ST[(pos * 2)].to) return calc((pos * 2), from, to, st);
  if (from >= ST[(pos * 2 + 1)].from) return calc((pos * 2 + 1), from, to, st);
  int tot = 0;
  int L = calc((pos * 2), from, ST[(pos * 2)].to, st);
  tot += L;
  tot -= (L % 60);
  int R = calc((pos * 2 + 1), ST[(pos * 2 + 1)].from, to, (L % 60));
  tot += R;
  if (x.from == from && x.to == to) {
    x.calc |= (1ll << st);
    x.val[st] = tot;
  }
  return tot;
}
int main() {
  char type;
  int n, nQ, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  make_tree(1, 1, n);
  scanf("%d", &nQ);
  for (int i = 0; i < nQ; i++) {
    scanf(" %c %d %d", &type, &x, &y);
    if (type == 'C')
      change(1, x, y);
    else
      printf("%d\n", calc(1, x, y - 1, 0));
  }
  return 0;
}
