#include <bits/stdc++.h>
inline int lb(int a) { return a & (-a); }
long long a[100100], bit[7][15][100100];
int n, m, t;
inline void adj(int z, int zm, int pos, long long val) {
  for (int i = pos; i <= n; i += lb(i)) bit[z][zm][i] += val;
}
inline long long qry(int z, int zm, int pos) {
  if (pos <= 0) return 0;
  long long rt = 0;
  for (int i = pos; i > 0; i -= lb(i)) rt += bit[z][zm][i];
  return rt;
}
inline long long sum(int z, int zm, int l, int r) {
  int z2 = z * 2 - 2;
  int lb = l + zm - 1, rb = r;
  if (lb > r) return 0;
  while (rb % z2 != lb % z2) rb--;
  lb -= z2;
  if (rb < l) return 0;
  return qry(z, rb % z2, rb) - qry(z, lb % z2, lb);
}
inline int s(int z, int i) {
  int mod = i % (2 * z - 2);
  if (mod == 0)
    return 2;
  else if (mod <= z)
    return mod;
  else
    return 2 * z - mod;
}
inline void update(int p, int v) {
  for (int z = 2; z <= 6; z++) {
    int z2 = z * 2 - 2;
    adj(z, p % z2, p, v - a[p]);
  }
  a[p] = v;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int in;
    scanf("%d", &in);
    update(i, in);
  }
  scanf("%d", &m);
  while (m-- > 0) {
    scanf("%d", &t);
    if (t == 1) {
      int p, v;
      scanf("%d%d", &p, &v);
      update(p, v);
    } else {
      int l, r, z;
      scanf("%d%d%d", &l, &r, &z);
      long long ans = 0;
      int z2 = z * 2 - 2;
      for (int i = 1; i <= z2; i++) {
        ans += s(z, i) * sum(z, i, l, r);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
