#include <bits/stdc++.h>
using namespace std;
const int l = 1 << 17, size = (2 * (1 << 17) - 1) + 1;
long long T[7][11][size];
long long Z(long long z, long long i) {
  long long r = i % (2 * (z - 1));
  if (r == 0) return 2;
  if (r > 0 && r <= z) return r;
  return 2 * z - r;
}
void Zmien(int i, int j, int k, int x) {
  k += l;
  T[i][j][k] = x;
  k /= 2;
  while (k != 0) {
    T[i][j][k] = T[i][j][2 * k] + T[i][j][2 * k + 1];
    k /= 2;
  }
}
long long Suma(int i, int j, int a, int b) {
  a += l;
  b += l;
  long long s = T[i][j][a];
  if (a != b) s += T[i][j][b];
  while (a / 2 != b / 2) {
    if (a % 2 == 0) s += T[i][j][a + 1];
    if (b % 2 == 1) s += T[i][j][b - 1];
    a /= 2;
    b /= 2;
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < 7; ++i)
    for (int j = 0; j < 11; ++j)
      for (int k = 0; k <= size; ++k) T[i][j][k] = 0;
  for (int i = 2; i <= 6; ++i) {
    int T = 2 * (i - 1);
    for (int j = 0; j < T; ++j)
      for (int k = j; k < n; k += T) Zmien(i, j, k, a[k]);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int p, v;
      cin >> p >> v;
      --p;
      for (int j = 2; j <= 6; ++j) {
        int T = 2 * (j - 1);
        Zmien(j, p % T, p, v);
      }
    } else {
      int l, r, z;
      cin >> l >> r >> z;
      --l;
      --r;
      long long odp = 0;
      int T = 2 * (z - 1);
      for (int j = 0; j < T; ++j)
        odp += Suma(z, (l + j) % T, l, r) * Z(z, j + 1);
      cout << odp << endl;
    }
  }
  return 0;
}
