#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
long long T[7][11][N] = {0}, ans;
int n, m, a[N], c, l, r, z;
void update(int zz, int mod, int x, int v) {
  while (x <= n) T[zz][mod][x] += v, x += x & -x;
}
long long getres(int zz, int mod, int x) {
  long long res = 0;
  while (x) res += T[zz][mod][x], x -= x & -x;
  return res;
}
long long S(int i, int z) {
  if (i % (2 * (z - 1)) == 0) return 2;
  if (i % (2 * (z - 1)) > z)
    return 2 * z - i % (2 * (z - 1));
  else
    return i % (2 * (z - 1));
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++i) {
    for (int zz = 2; zz <= 6; ++zz) update(zz, i % (2 * (zz - 1)), i, a[i]);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &c);
    if (c == 1) {
      scanf("%d%d", &l, &r);
      for (int zz = 2; zz <= 6; ++zz) update(zz, l % (2 * (zz - 1)), l, -a[l]);
      a[l] = r;
      for (int zz = 2; zz <= 6; ++zz) update(zz, l % (2 * (zz - 1)), l, a[l]);
    } else {
      ans = 0;
      scanf("%d%d%d", &l, &r, &z);
      for (int j = l; j <= min(r, l + 2 * z - 3); ++j)
        ans += 1LL *
               (getres(z, j % (2 * (z - 1)), r) -
                getres(z, j % (2 * (z - 1)), l - 1)) *
               S(j - l + 1, z);
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
