#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1000000000;
template <class T>
T read(T &x) {
  char c;
  int flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag *= -1;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= flag;
  return x;
}
int n;
int lt[100005];
int g[100005];
int dp[100005][65];
int sz = 100;
int a[100005];
char cmd;
int x, y;
int ans;
int st;
int i, j, r, gr;
int main() {
  read(n);
  for (i = 1; i <= n; ++i) read(a[i]);
  for (gr = 1, i = 1; i <= n; i += sz, gr++) {
    lt[gr] = min(n, i + sz - 1);
    g[lt[gr]] = gr;
    for (j = lt[gr] - 1; j >= i; --j) {
      g[j] = gr;
      for (r = 0; r < 60; ++r) {
        if (r % a[j] == 0)
          dp[j][r] = 2 + dp[j + 1][(r + 2) % 60];
        else
          dp[j][r] = 1 + dp[j + 1][(r + 1) % 60];
      }
    }
  }
  int q;
  read(q);
  while (q--) {
    cmd = '#';
    while (!isalpha(cmd)) cmd = getchar();
    read(x);
    read(y);
    if (cmd == 'A') {
      ans = 0;
      while (g[x] != g[y]) {
        ans += dp[x][ans % 60];
        x = lt[g[x]];
        if (ans % a[x] == 0)
          ans += 2;
        else
          ans++;
        x++;
      }
      while (x < y) {
        if (ans % a[x] == 0)
          ans += 2;
        else
          ans++;
        x = x + 1;
      }
      printf("%d\n", ans);
    } else {
      a[x] = y;
      st = (g[x] - 1) * sz + 1;
      if (lt[g[x]] == x) x--;
      for (j = x; j >= st; --j) {
        for (r = 0; r < 60; ++r) {
          if (r % a[j] == 0)
            dp[j][r] = 2 + dp[j + 1][(r + 2) % 60];
          else
            dp[j][r] = 1 + dp[j + 1][(r + 1) % 60];
        }
      }
    }
  }
}
