#include <iostream>
#include <vector>
using namespace std;
vector<int> tree;
int n;
int gcd (int a, int b){
if (a == 0) return b;
return gcd(b % a, a);
}
void build(int a[], int v = 1, int tl = 0, int tr = n - 1){
if(tl == tr){
tree[v] = a[tl];
}else{
int middle = (tl + tr) / 2;
build(a, v * 2, tl, middle);
build(a, v * 2 + 1, middle + 1, tr);
tree[v] = gcd(tree[v * 2], tree[v * 2 + 1]);
}
}
int get(int a[], int l, int r, int v = 1, int tl = 0, int tr = n-1){
if(l > r){
return 0;
}
if(tl == l && tr == r){
return tree[v];
}
int middle = (tl + tr) / 2;
int L = get(a, l, min(middle, r), v * 2, tl, middle);
int R = get(a, max(middle + 1, l), r, v*2 + 1, middle + 1, tr);
return gcd(L, R);
}
void update(int pos, int val, int v = 1, int tl = 0, int tr = n - 1){
if(tl == tr){
tree[v] = val;
}else{
int middle = (tl + tr) / 2;
if(pos <= middle){
update(pos, val, v * 2, tl, middle);
}else{
update(pos, val, v * 2 + 1, middle + 1, tr);
}
tree[v] = gcd(tree[v * 2], tree[v * 2 + 1]);
}
}
int main(){
cin >> n;
int a[n];
for (int i = 0; i < n; i++){
cin >> a[i];
}
tree.resize(4 * n);
build(a);
int m, l, r, q;
cin >> m;
while (m--){
cin >> q >> l >> r;
if (q == 1){
cout << get(a, l - 1, r - 1) << endl;
}
else{
update(l - 1, r);
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdmVjdG9yPGludD4gdHJlZTsKaW50IG47CgppbnQgZ2NkIChpbnQgYSwgaW50IGIpewogICAgaWYgKGEgPT0gMCkgcmV0dXJuIGI7CiAgIHJldHVybiBnY2QoYiAlIGEsIGEpOwp9CnZvaWQgYnVpbGQoaW50IGFbXSwgaW50IHYgPSAxLCBpbnQgdGwgPSAwLCBpbnQgdHIgPSBuIC0gMSl7CiAgICBpZih0bCA9PSB0cil7CiAgICAgICAgdHJlZVt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ZGxlICsgMSwgdHIpOwogICAgICAgIH0KICAgICAgICB0cmVlW3ZdID0gZ2NkKHRyZWVbdiAqIDJdLCB0cmVlW3YgKiAyICsgMV0pOwogICAgfQp9CiAKaW50IG1haW4oKXsKICAgIGNpbiA+PiBuOwogICAgaW50IGFbbl07CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgY2luID4+IGFbaV07CiAgICB9CiAgICB0cmVlLnJlc2l6ZSg0ICogbik7CiAgICBidWlsZChhKTsKICAgIGludCBtLCBsLCByLCBxOyAKICAgIGNpbiA+PiBtOwogICAgd2hpbGUgKG0tLSl7CiAgICAgICAgY2luID4+IHEgPj4gbCA+PiByOwogICAgICAgIGlmIChxID09IDEpewogICAgICAgICAgICBjb3V0IDw8IGdldChhLCBsIC0gMSwgciAtIDEpIDw8IGVuZGw7CiAgICAgICAgfQogICAgICAgIGVsc2V7CiAgICAgICAgCXVwZGF0ZShsIC0gMSwgcik7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0=