#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9;
const int inf = (int)1e9;
const int base = 1000 * 1000 * 1000;
const int maxn = 1005;
const long double pi = acosl(-1.0);
const long double eps = 1e-9;
void error() { exit(1); }
long long f(int i, int z, int d) {
  int res = (i + d + 1) % (2 * (z - 1));
  if (res == 0)
    return 2;
  else if (res <= z)
    return res;
  return 2 * z - res;
}
struct Tree {
  vector<long long> t;
  int size;
  void init(vector<int> &a, int n, int z, int del) {
    size = 1;
    while (n >= size) size <<= 1;
    t.resize(size << 1, 0);
    for (int i = 0; i < n; i++) {
      t[i + size] = a[i] * f(i, z, del);
    }
    for (int i = size - 1; i >= 1; i--) t[i] = t[2 * i] + t[2 * i + 1];
  }
  void change(int v, int val, int z, int del) {
    v = size + v;
    t[v] = val * f(v - size, z, del);
    while ((v >> 1) >= 1) {
      v >>= 1;
      t[v] = t[2 * v] + t[2 * v + 1];
    }
  }
  long long get(int v, int curl, int curr, int l, int r) {
    if (l > r) return 0;
    if (curl == l && curr == r) return t[v];
    int mid = (curl + curr) >> 1;
    long long a = get(2 * v, curl, mid, l, min(r, mid));
    long long b = get(2 * v + 1, mid + 1, curr, max(l, mid + 1), r);
    return a + b;
  }
};
void solve() {
  Tree tree[10][20];
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 2; i < 7; i++)
    for (int j = 0; j < 2 * (i - 1); j++) {
      tree[i][j].init(a, n, i, j);
    }
  int m, t;
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &t);
    if (t == 1) {
      int p, v;
      scanf("%d %d", &p, &v);
      for (int i = 2; i < 7; i++)
        for (int j = 0; j < 2 * (i - 1); j++) {
          tree[i][j].change(p - 1, v, i, j);
        }
    } else {
      int l, r, z;
      scanf("%d %d %d", &l, &r, &z);
      int ost = (l - 1) % (2 * (z - 1));
      int del = (2 * (z - 1) - ost) % (2 * (z - 1));
      long long ans =
          tree[z][del].get(1, 0, tree[z][del].size - 1, l - 1, r - 1);
      printf("%I64d\n", ans);
    }
  }
}
int main() {
  solve();
  return 0;
}
