#include <bits/stdc++.h>
using namespace std;
struct node {
  int cnt[60];
  int to[60];
  node() {
    for (int i = 0; i < (60); i++) {
      cnt[i] = 0;
      to[i] = i;
    }
  }
  node merge(const node &b) {
    node res;
    for (int i = 0; i < (60); i++) {
      res.to[i] = b.to[to[i]];
      res.cnt[i] = b.cnt[to[i]] + cnt[i];
    }
    return res;
  }
  void makeNode(int a) {
    for (int i = 0; i < 60; i++) {
      if (i % a == 0)
        to[i] = (i + 2);
      else
        to[i] = (i + 1);
      cnt[i] = 0;
      if (to[i] >= 60) {
        to[i] -= 60;
        cnt[i] = 1;
      }
    }
  }
};
const int MAXN = 131072 * 2;
struct SegmentTree {
  node nd[MAXN];
  int ds;
  static int getds(int n) {
    n--;
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    return n + 1;
  }
  SegmentTree(int n, int *a) {
    ds = getds(n);
    for (int i = 0; i < (n); i++) nd[i + ds].makeNode(a[i]);
    for (int i = ds - 1; i > 0; i--) nd[i] = nd[2 * i].merge(nd[2 * i + 1]);
  }
  node getRes(int l, int r) {
    l += ds;
    r += ds;
    node lRes, rRes;
    while (l <= r) {
      if (l & 1) lRes = lRes.merge(nd[l++]);
      if (~r & 1) rRes = (nd[r--]).merge(rRes);
      l >>= 1;
      r >>= 1;
    }
    return lRes.merge(rRes);
  }
  void update(int i, int a) {
    i += ds;
    nd[i].makeNode(a);
    i >>= 1;
    while (i) {
      nd[i] = nd[2 * i].merge(nd[2 * i + 1]);
      i >>= 1;
    }
  }
};
int a[MAXN];
SegmentTree *s;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", &a[i]);
  s = new SegmentTree(n, a);
  int q;
  scanf("%d", &q);
  while (q--) {
    char buf[10];
    scanf("%s", buf);
    if (buf[0] == 'A') {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      r -= 2;
      node res = s->getRes(l, r);
      printf("%d\n", res.cnt[0] * 60 + res.to[0]);
    } else {
      int x, a;
      scanf("%d%d", &x, &a);
      x--;
      s->update(x, a);
    }
  }
  return 0;
}
