#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
struct seg_tree {
  int left, right;
  long long sum[7][10];
} L[maxn << 2];
int s[7][10];
int n, m, a[maxn];
void init() {
  for (int i = 2; i <= 6; i++) {
    for (int j = 0; j < 2 * (i - 1); j++) {
      if (j == 0)
        s[i][j] = 2;
      else if (j <= i)
        s[i][j] = j;
      else
        s[i][j] = 2 * i - j;
    }
  }
}
void push_up(int step) {
  for (int i = 2; i <= 6; i++) {
    for (int j = 0; j < 2 * (i - 1); j++) {
      int d = L[step << 1].right - L[step << 1].left + 1;
      L[step].sum[i][j] = (L[step << 1].sum[i][j] +
                           L[step << 1 | 1].sum[i][(j + d) % (2 * (i - 1))]);
    }
  }
}
void build(int step, int l, int r) {
  L[step].left = l, L[step].right = r;
  if (l == r) {
    for (int i = 2; i <= 6; i++) {
      for (int j = 0; j < 2 * (i - 1); j++) {
        L[step].sum[i][j] = (long long)s[i][j] * a[l];
      }
    }
    return;
  }
  int m = (l + r) >> 1;
  build(step << 1, l, m);
  build(step << 1 | 1, m + 1, r);
  push_up(step);
}
long long query(int step, int l, int r, int z, int x) {
  if (L[step].left == l && L[step].right == r) return L[step].sum[z][x];
  int m = (L[step].left + L[step].right) >> 1;
  if (r <= m)
    return query(step << 1, l, r, z, x);
  else if (l > m)
    return query(step << 1 | 1, l, r, z, x);
  else
    return query(step << 1, l, m, z, x) +
           query(step << 1 | 1, m + 1, r, z, (x + (m - l + 1)) % (2 * (z - 1)));
}
void update(int step, int pos, int val) {
  if (L[step].left == pos && L[step].right == pos) {
    for (int i = 2; i <= 6; i++) {
      for (int j = 0; j < 2 * (i - 1); j++)
        L[step].sum[i][j] = (long long)val * s[i][j];
    }
    return;
  }
  int m = (L[step].left + L[step].right) >> 1;
  if (pos <= m)
    update(step << 1, pos, val);
  else
    update(step << 1 | 1, pos, val);
  push_up(step);
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, 1, n);
  scanf("%d", &m);
  while (m--) {
    int k, l, r, z;
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d%d", &l, &z);
      update(1, l, z);
    } else {
      scanf("%d%d%d", &l, &r, &z);
      printf("%lld\n", query(1, l, r, z, 1));
    }
  }
}
