#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000")
using namespace std;
int c, v, c1, v1, *a[262144], *s[262144];
void l(int w, int e, int t) {
  w <<= 1;
  if ((c <= e) && (e + t - 1 <= v)) {
    c1 += a[w][v1];
    v1 = s[w][v1];
  } else if (min(v, e + t - 1) - max(c, e) >= 0)
    l(w, e, t >> 1);
  if ((c <= e + t) && (e + t + t - 1 <= v)) {
    c1 += a[w + 1][v1];
    v1 = s[w + 1][v1];
  } else if (min(v, e + t + t - 1) - max(c, e + t) >= 0)
    l(w + 1, e + t, t >> 1);
}
int main() {
  int q, w, e, r, t, o;
  for (w = 0; w < 262144; w++) {
    a[w] = new int[60];
    s[w] = new int[60];
  }
  cin >> q;
  for (w = 0; w < q; w++) {
    cin >> e;
    for (r = 0; r < 60; r++) {
      c = 1;
      if (r % e == 0) c++;
      a[w + 131072][r] = c;
      s[w + 131072][r] = (c + r) % 60;
    }
  }
  for (; w < 131072; w++)
    for (r = 0; r < 60; r++) a[w + 131072][r] = s[w + 131072][r] = 1;
  for (w = 131071; w; w--)
    for (e = 0; e < 60; e++) {
      c = s[w << 1][e];
      a[w][e] = a[w << 1][e] + a[(w << 1) + 1][c];
      s[w][e] = s[(w << 1) + 1][c];
    }
  char d[2];
  for (cin >> o; o; o--) {
    scanf("%s%d%d", &d, &c, &v);
    if (d[0] == 'A') {
      c1 = v1 = 0;
      c--;
      v -= 2;
      l(1, 0, 65536);
      printf("%d\n", c1);
    } else {
      c += 131071;
      for (e = 0; e < 60; e++) {
        r = 1;
        if (e % v == 0) r++;
        a[c][e] = r;
        s[c][e] = (r + e) % 60;
      }
      for (c >>= 1; c; c >>= 1)
        for (e = 0; e < 60; e++) {
          r = s[c << 1][e];
          a[c][e] = a[c << 1][e] + a[(c << 1) + 1][r];
          s[c][e] = s[(c << 1) + 1][r];
        }
    }
  }
  return 0;
}
