#include <bits/stdc++.h>
using namespace std;
int n, ar[1 << 20];
long long t[7][14][200000];
int tests;
int Z[20], coef[20][20];
int ps, val;
long long sum(int a, int b, int r) {
  long long res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) res += t[a][b][r];
  return res;
}
void inc(int a, int b, int i, long long val) {
  for (; i < 200000; i = (i | (i + 1))) t[a][b][i] += val;
}
long long sum(int a, int b, int l, int r) {
  return sum(a, b, r) - sum(a, b, l - 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int i = 1; i <= 6; i++) Z[i] = i * 2 - 2;
  for (int z = 2; z <= 6; z++) {
    for (int j = 1; j <= z * 2 - 2; j++) {
      coef[z][j - 1] = j % (2 * z - 2);
      if (coef[z][j - 1] > z) coef[z][j - 1] = 2 * z - coef[z][j - 1];
      if (coef[z][j - 1] == 0) coef[z][j - 1] = 2;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int z = 2; z <= 6; z++)
      for (int rem = 0; rem < 2 * z - 2; rem++) {
        int trem = i + 2 * z - 2 - rem;
        trem %= (2 * z - 2);
        inc(z, rem, i, ar[i] * 1ll * coef[z][trem]);
      }
  }
  cin >> tests;
  for (; tests; --tests) {
    int tp;
    cin >> tp;
    if (tp == 2) {
      int l, r, z;
      cin >> l >> r >> z;
      --l;
      --r;
      long long ans = 0;
      ans = sum(z, l % (z * 2 - 2), l, r);
      cout << ans << endl;
    } else {
      cin >> ps >> val;
      --ps;
      int dif = val - ar[ps];
      ar[ps] = val;
      for (int z = 2; z <= 6; z++) {
        for (int rem = 0; rem < (z * 2 + 2); rem++) {
          int trem = ps + z * 2 - 2 - rem;
          trem %= (z * 2 - 2);
          inc(z, rem, ps, dif * 1ll * coef[z][trem]);
        }
      }
    }
  }
  return 0;
}
