#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define lowbit(x) x & -x
typedef long long LL;
using namespace std;
const int N = 500010;
LL n, m;
LL a[N], tr1[N];
void add(LL x, LL v) {
for (LL i = x; i <= n; i += lowbit(i)) tr1[i] += v;
}
LL sum(LL x) {
LL res = 0;
for (LL i = x; i; i -= lowbit(i)) res += tr1[i];
return res;
}
struct T {
int l, r;
LL v;
}tr[N * 4];
inline void pushup(int u) {
tr[u].v = gcd(tr[u << 1].v, tr[u << 1 | 1].v);
}
void build(int u, int l, int r) {
if (l == r) tr[u] = {l, r, a[r] - a[r - 1]};
else {
tr[u] = {l, r};
LL mid = l + r >> 1;
build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
pushup(u);
}
}
void modify(int u, int x, LL v)
{
if (tr[u].l == x && tr[u].r == x) tr[u].v += v;
else
{
LL mid = tr[u].l + tr[u].r >> 1;
if (x <= mid) modify(u << 1, x, v);
else modify(u << 1 | 1, x, v);
pushup(u);
}
}
LL query(int u, int l, int r) {
if (l > r) return 0;
if (tr[u].l >= l && tr[u].r <= r) return tr[u].v;
else {
LL mid = tr[u].l + tr[u].r >> 1;
LL v = 0;
if (l <= mid ) v = query(u << 1, l, r);
if (r > mid) v = gcd(v, query(u << 1 | 1, l, r));
return v;
}
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i ++) scanf("%lld", &a[i]), add(i, a[i] - a[i - 1]);
build(1, 1, n + 1);
char op;
int l, r;
LL d;
for(; m --; ) {
scanf(" %c%d%d", &op, &l, &r);
if (op == 'Q') {
LL left = sum(l);
LL right = query(1, l + 1, r);
printf("%lld\n", abs(gcd(left, right)));
} else {
scanf("%lld", &d);
add(l, d), add(r + 1, -d);
modify(1, l, d), modify(1, r + 1, -d);
}
}
return 0;
}