#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;
constexpr int kMaxN = 300000 + 1;
constexpr int kBuffSize = 4096;
constexpr int NIL = -1;
int foo[kMaxN];
long long tree[kMaxN];
struct List {
int divisor;
int next;
} buff[kMaxN * 20];
int head[kMaxN];
inline char get_char() {
static char buff[kBuffSize];
static int pos = kBuffSize;
if (pos == kBuffSize) {
fread(buff, 1, kBuffSize, stdin);
pos = 0;
}
return buff[pos++];
}
inline int read_int() {
int q = 0;
char c;
do {
c = get_char();
} while (not isdigit(c));
do {
q = (q << 1) + (q << 3) + (c - '0');
c = get_char();
} while (isdigit(c));
return q;
}
void fenwick_update(const int position, const int m_size,
const int delta) {
for (int i = position; i <= m_size; i += (i & -i)) {
tree[i] += delta;
}
}
long long fenwick_query(const int position) {
long long ret = 0LL;
for (int i = position; i > 0; i -= (i & -i)) {
ret += tree[i];
}
return ret;
}
void get_divisors(const int n) {
int buff_size = 0;
memset(head + 1, NIL, 4 * n);
for (int i = 1; i <= n; i += 1) {
for (int j = i; j <= n; j += i) {
buff[buff_size].divisor = i;
buff[buff_size].next = head[j];
head[j] = buff_size++;
}
}
}
int main() {
int n = read_int();
for (int i = 1; i <= n; i += 1) {
foo[i] = read_int();
}
get_divisors(n);
int q = read_int();
for (int iter = 0; iter < q; iter += 1) {
int op_type = read_int();
if (op_type == 2) {
int lo = read_int(), hi = read_int(), delta = read_int();
fenwick_update(lo, n, delta);
fenwick_update(hi + 1, n, -delta);
} else {
int pos = read_int();
long long ret = foo[pos];
for (int i = head[pos]; i != NIL; i = buff[i].next) {
ret += fenwick_query(buff[i].divisor);
}
printf("%lld\n", ret);
}
}
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGNzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdGV4cHIgaW50IGtNYXhOID0gMzAwMDAwICsgMTsKY29uc3RleHByIGludCBrQnVmZlNpemU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ICAgIGxvbmcgbG9uZyByZXQgPSAwTEw7CiAgICBmb3IgKGludCBpID0gcG9zaXRpb247IGkgPiAwOyBpIC09IChpICYgLWkpKSB7CiAgICAgICAgcmV0ICs9IHRyZWVbaV07CiAgICB9CiAgICByZXR1cm4gcmV0Owp9Cgp2b2lkIGdldF9kaXZpc29ycyhjb25zdCBpbnQgbikgewogICAgaW50IGJ1ZmZfc2l6ZSA9IDA7CiAgICBtZW1zZXQoaGVhZCArIDEsIE5JTCwgNCAqIG4pOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSArPSAxKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IGk7IGogPD0gbjsgaiArPSBpKSB7CiAgICAgICAgICAgIGJ1ZmZbYnVmZl9zaXplXS5kaXZpc29yID0gaTsKICAgICAgICAgICAgYnVmZltidWZmX3NpemVdLm5leHQgPSBoZWFkW2pdOwogICAgICAgICAgICBoZWFkW2pdID0gYnVmZl9zaXplKys7CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCBuID0gcmVhZF9pbnQoKTsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkgKz0gMSkgewogICAgICAgIGZvb1tpXSA9IHJlYWRfaW50KCk7CiAgICB9CiAgICAKICAgIGdldF9kaXZpc29ycyhuKTsKCiAgICBpbnQgcSA9IHJlYWRfaW50KCk7CiAgICBmb3IgKGludCBpdGVyID0gMDsgaXRlciA8IHE7IGl0ZXIgKz0gMSkgewogICAgICAgIGludCBvcF90eXBlID0gcmVhZF9pbnQoKTsKICAgICAgICBpZiAob3BfdHlwZSA9PSAyKSB7CiAgICAgICAgICAgIGludCBsbyA9IHJlYWRfaW50KCksIGhpID0gcmVhZF9pbnQoKSwgZGVsdGEgPSByZWFkX2ludCgpOwogICAgICAgICAgICBmZW53aWNrX3VwZGF0ZShsbywgbiwgZGVsdGEpOwogICAgICAgICAgICBmZW53aWNrX3VwZGF0ZShoaSArIDEsIG4sIC1kZWx0YSk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgaW50IHBvcyA9IHJlYWRfaW50KCk7CiAgICAgICAgICAgIGxvbmcgbG9uZyByZXQgPSBmb29bcG9zXTsKICAgICAgICAgICAgZm9yIChpbnQgaSA9IGhlYWRbcG9zXTsgaSAhPSBOSUw7IGkgPSBidWZmW2ldLm5leHQpIHsKICAgICAgICAgICAgICAgIHJldCArPSBmZW53aWNrX3F1ZXJ5KGJ1ZmZbaV0uZGl2aXNvcik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJpbnRmKCIlbGxkXG4iLCByZXQpOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9