#define ll long long #define INF 2147483647 #define lc(a) ((a) << 1) #define rc(a) ((a) << 1 | 1)
intinp(){ char c = getchar(); while(c < '0' || c > '9') c = getchar(); int sum = 0; while(c >= '0' && c <= '9'){ sum = sum * 10 + c - '0'; c = getchar(); } return sum; }
int a[100010]; structSEG_Tree{ structSEG{ int l; int r; int f[61]; }t[400010];
voidpush_up(int cur){ for(int i = 0; i < 60; i++) t[cur].f[i] = t[rc(cur)].f[(i + t[lc(cur)].f[i]) % 60] + t[lc(cur)].f[i]; }
voidbuild(int cur, int l, int r){ t[cur].l = l; t[cur].r = r; if(l == r){ for(int i = 59; i >= 0; i--) t[cur].f[i] = 1 + (i % a[l] == 0); return ; } int mid = (l + r) >> 1; build(lc(cur), l, mid); build(rc(cur), mid + 1, r); push_up(cur); }
voidmodify(int cur, int x, int c){ if(t[cur].l == t[cur].r){ a[x] = c; for(int i = 59; i >= 0; i--) t[cur].f[i] = 1 + (i % a[x] == 0); return ; } if(x <= t[lc(cur)].r) modify(lc(cur), x, c); else modify(rc(cur), x, c); push_up(cur); }
intquery(int cur, int l, int r, int x){ if(t[cur].l > r || t[cur].r < l) return0; if(t[cur].l >= l && t[cur].r <= r){ // printf("[%d, %d].f[%d] = %d\n", t[cur].l, t[cur].r, x, t[cur].f[x]); return t[cur].f[x]; } int ls = query(lc(cur), l, r, x); return ls + query(rc(cur), l, r, (x + ls) % 60); } }t;
intmain(){ int n = inp(); for(int i = 1; i <= n; i++) a[i] = inp(); t.build(1, 1, n); int m = inp(); while(m--){ char op = getchar(); while(op != 'C' && op != 'A') op = getchar(); if(op == 'C'){ int x = inp(); int c = inp(); t.modify(1, x, c); } else { int l = inp(); int r = inp() - 1; printf("%d\n", t.query(1, l, r, 0)); } } }