#include <bits/stdc++.h>
using namespace std;
int n, m, A[100005];
struct BIT {
  long long arr[100005];
  int sz;
  void add(int pos, int val) {
    while (pos <= sz) {
      arr[pos] += (long long)val;
      pos += pos & -pos;
    }
  }
  long long sum(int pos) {
    long long S = 0;
    while (pos > 0) {
      S += arr[pos];
      pos -= pos & -pos;
    }
    return S;
  }
} ars[5][10];
inline int cals(int i, int z) {
  return ((!(i % ((z << 1) - 2))) ? (2)
                                  : ((i % ((z << 1) - 2) <= z)
                                         ? (i % ((z << 1) - 2))
                                         : ((z << 1) - (i % ((z << 1) - 2)))));
}
inline int app(int i, int z) { return (i + (z << 1) - 3) / ((z << 1) - 2); }
inline int inc(int i, int z, int m) {
  z = (z << 1) - 2;
  if (m) {
    return ((i - m + z) / z);
  } else {
    return (i / z);
  }
}
int main() {
  int p, v, xb, x2, t, l, r, z;
  scanf("%d", &n);
  for (xb = 0; xb < 5; xb++)
    for (x2 = 0; x2 < 10; x2++) ars[xb][x2].sz = n;
  for (xb = 1; xb <= n; xb++) {
    scanf("%d", &A[xb]);
    for (x2 = 2; x2 <= 6; x2++) {
      ars[x2 - 2][xb % ((x2 << 1) - 2)].add(app(xb, x2), A[xb]);
    }
  }
  scanf("%d", &m);
  for (xb = 0; xb < m; xb++) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%d", &p, &v);
      for (x2 = 2; x2 <= 6; x2++) {
        ars[x2 - 2][p % ((x2 << 1) - 2)].add(app(p, x2), v - A[p]);
      }
      A[p] = v;
    } else {
      scanf("%d%d%d", &l, &r, &z);
      long long res = 0;
      for (x2 = 0; x2 < (z << 1) - 2; x2++) {
        res += (long long)cals(x2 + 100000 * ((z << 1) - 2) - l + 1, z) *
               (ars[z - 2][x2].sum(inc(r, z, x2)) -
                ars[z - 2][x2].sum(inc(l - 1, z, x2)));
      }
      printf("%I64d\n", res);
    }
  }
  return 0;
}
