#include <bits/stdc++.h>
using namespace std;
inline int mmod(int n, int z, int l) {
  int mod = 2 * z - 2;
  return ((n - l) % mod + mod) % mod;
}
vector<vector<long long> > z;
struct ST {
  int n;
  vector<long long> t;
  int x, y;
  ST() {}
  ST(const vector<long long> &a, int _x, int _y) {
    x = _x;
    y = _y;
    n = 1;
    int _n = (int)a.size();
    while (n < _n) n <<= 1;
    t.clear();
    t.resize(2 * n);
    for (int i = n; i < n + _n; i++) t[i] = a[i - n] * z[x][mmod(i - n, x, y)];
    for (int i = n - 1; i > 0; i--) t[i] = t[i << 1] + t[(i << 1) + 1];
  }
  inline void update(int v, int val) {
    v += n;
    t[v] = (long long)val * z[x][mmod(v - n, x, y)];
    v >>= 1;
    while (v) t[v] = t[v << 1] + t[(v << 1) + 1], v >>= 1;
  }
  inline long long get(int v, int a, int b, int l, int r) {
    if (r < a || b < l) return 0;
    if (l <= a && b <= r) return t[v];
    int m = (a + b) >> 1;
    return get(v << 1, a, m, l, r) + get((v << 1) + 1, m + 1, b, l, r);
  }
  inline long long get(int l, int r) {
    return get(1, n, (n << 1) - 1, l + n, r + n);
  }
};
int n;
vector<long long> a;
int main() {
  while (scanf("%d", &n) >= 1) {
    z.resize(7);
    for (int i = 2; i <= 6; i++) {
      z[i].resize(2 * i - 2);
      for (int j = 0; j < i; j++) z[i][j] = j + 1;
      for (int j = i; j < 2 * i - 2; j++) z[i][j] = (i << 1) - j - 1;
    }
    a.resize(n);
    for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
    vector<ST> trees[7];
    for (int i = 2; i <= 6; i++) {
      trees[i].resize(2 * i - 2);
      for (int j = 0; j < 2 * i - 2; j++) trees[i][j] = ST(a, i, j);
    }
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
      int type;
      scanf("%d", &type);
      if (type == 1) {
        int p, v;
        scanf("%d%d", &p, &v);
        --p;
        for (int z = 2; z <= 6; z++)
          for (int j = 0; j < 2 * z - 2; j++) trees[z][j].update(p, v);
      } else {
        int l, r, z;
        scanf("%d%d%d", &l, &r, &z);
        --l, --r;
        printf("%I64d\n", trees[z][l % (2 * z - 2)].get(l, r));
      }
    }
    break;
  }
  return 0;
}
