#include <bits/stdc++.h>
using namespace std;
const int N = 100005, M = 60;
struct Node {
  int tm[M];
  Node(int x = 2) {
    for (int i = 0; i < (M); ++i) {
      int cur = i;
      while (cur % x == 0) ++cur;
      tm[i] = cur - i + 1;
    }
  }
  Node operator+(const Node& y) const {
    Node res;
    for (int i = 0; i < (M); ++i) res.tm[i] = tm[i] + y.tm[(i + tm[i]) % M];
    return res;
  }
} seg[N << 2], res;
int n, m;
void modify(int c, int l, int r, int p, int x) {
  if (l == r)
    seg[c] = Node(x);
  else {
    int m = (l + r) >> 1;
    if (p <= m)
      modify(c << 1, l, m, p, x);
    else
      modify(c << 1 | 1, m + 1, r, p, x);
    seg[c] = seg[c << 1] + seg[c << 1 | 1];
  }
}
void query(int c, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr)
    res = res + seg[c];
  else {
    int m = (l + r) >> 1;
    if (ql <= m) query(c << 1, l, m, ql, qr);
    if (qr > m) query(c << 1 | 1, m + 1, r, ql, qr);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < (n + 1); ++i) scanf("%d", &m), modify(1, 1, n, i, m);
  scanf("%d", &m);
  for (int i = 0; i < (m); ++i) {
    char s[10];
    int l, r;
    scanf("%s%d%d", s, &l, &r);
    if (s[0] == 'C')
      modify(1, 1, n, l, r);
    else {
      for (int i = 0; i < (M); ++i) res.tm[i] = 0;
      query(1, 1, n, l, r - 1);
      printf("%d\n", res.tm[0]);
    }
  }
  return 0;
}
