#include <bits/stdc++.h>
using namespace std;
const int P = 60;
struct SegTree {
  int n;
  vector<vector<int> > t;
  SegTree(int n_) {
    n = 1;
    while (n < n_) n <<= 1;
    t.resize(2 * n - 1, vector<int>(P));
  }
  vector<int> calc(const vector<int> &u, const vector<int> &v) {
    vector<int> w(P);
    for (int i = 0; i < P; i++) {
      w[i] = v[(i + u[i]) % P] + u[i];
    }
    return w;
  }
  void update(int k, const vector<int> &v) {
    k += n - 1;
    t[k] = v;
    while (k > 0) {
      k = (k - 1) >> 1;
      t[k] = calc(t[2 * k + 1], t[2 * k + 2]);
    }
  }
  vector<int> query(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) {
      return vector<int>(P);
    } else if (a <= l && r <= b) {
      return t[k];
    } else {
      return calc(query(a, b, 2 * k + 1, l, (l + r) / 2),
                  query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
  }
  vector<int> query(int a, int b) { return query(a, b, 0, 0, n); }
};
int n, q;
int main() {
  vector<vector<int> > vs(7, vector<int>(P));
  for (int i = 2; i <= 6; i++) {
    for (int j = 0; j < P; j++) {
      int k = 0;
      while ((j + k) % i == 0) {
        k++;
      }
      vs[i][j] = k + 1;
    }
  }
  scanf("%d", &n);
  SegTree st(n);
  for (int i = 0; i < n; i++) {
    int v;
    scanf("%d", &v);
    st.update(i, vs[v]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    char c;
    scanf(" %c", &c);
    if (c == 'C') {
      int k, v;
      scanf("%d%d", &k, &v);
      k--;
      st.update(k, vs[v]);
    } else if (c == 'A') {
      int s, t;
      scanf("%d%d", &s, &t);
      s--, t--;
      printf("%d\n", st.query(s, t)[0]);
    } else {
      assert(false);
    }
  }
}
