#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int t[4 * 100005][61], b[100005];
void pushup(int k) {
  for (int i = 0; i < 60; i++)
    t[k][i] = t[(k << 1 | 1)][t[(k << 1)][i] % 60] + t[(k << 1)][i] / 60 * 60;
  return;
}
void build(int k, int l, int r) {
  if (l == r) {
    for (int i = 0; i < 60; i++) {
      if (i % b[l])
        t[k][i] = i + 1;
      else
        t[k][i] = i + 2;
    }
    return;
  }
  build((k << 1), l, ((l + r) / 2));
  build((k << 1 | 1), ((l + r) / 2) + 1, r);
  pushup(k);
  return;
}
int query(int k, int l, int r, int nl, int nr, int v) {
  if (l > nr || r < nl) return v;
  if (nl <= l && nr >= r) {
    return t[k][v % 60] + v / 60 * 60;
  }
  int k1 = query((k << 1), l, ((l + r) / 2), nl, nr, v);
  int k2 = query((k << 1 | 1), ((l + r) / 2) + 1, r, nl, nr, k1);
  return k2;
}
void modify(int k, int l, int r, int x, int y) {
  if (x < l || r < x) return;
  if (l == x && x == r) {
    b[l] = y;
    for (int i = 0; i < 60; i++) {
      if (i % b[l])
        t[k][i] = i + 1;
      else
        t[k][i] = i + 2;
    }
    return;
  }
  modify((k << 1), l, ((l + r) / 2), x, y);
  modify((k << 1 | 1), ((l + r) / 2) + 1, r, x, y);
  pushup(k);
  return;
}
int n;
void init() {
  n = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  build(1, 1, n);
  return;
}
void solve() {
  int q = read();
  while (q--) {
    char c[2];
    cin >> c;
    int x = read(), y = read();
    if (c[0] == 'A')
      printf("%d\n", query(1, 1, n, x, y - 1, 0));
    else
      modify(1, 1, n, x, y);
  }
  return;
}
int main() {
  init();
  solve();
  return 0;
}
