#include <bits/stdc++.h>
using namespace std;
long long a[11][100010] = {0};
long long sum(int k, int dir) {
  long long ans = 0;
  int r = k % dir;
  k = k / dir + 1;
  while (k > 0) {
    ans += a[dir][(k - 1) * dir + r];
    k -= k & (-k);
  }
  return ans;
}
void update(int k, int dir, long long num) {
  int r = k % dir;
  k = k / dir + 1;
  while ((k - 1) * dir + r < 100010) {
    a[dir][(k - 1) * dir + r] += num;
    k += k & (-k);
  }
}
long long calc(int dir, int start, int end) {
  int r = start % dir;
  if (end / dir * dir + r > end)
    end = end / dir * dir + r - dir;
  else
    end = end / dir * dir + r;
  long long ans = sum(end, dir);
  if (start - dir > 0) ans -= sum(start - dir, dir);
  return ans;
}
int fz(int i, int z) {
  int r = i % (2 * (z - 1));
  if (r == 0)
    return 2;
  else if (r <= z)
    return r;
  else
    return 2 * z - r;
}
long long b[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &b[i]);
    for (int j = 1; j <= 10; j++) {
      update(i, j, b[i]);
    }
  }
  int q;
  int t, p;
  long long v;
  scanf("%d", &q);
  int l, r, z;
  long long ans = 0;
  while (q--) {
    scanf("%d", &t);
    if (t == 1) {
      scanf("%d%I64d", &p, &v);
      long long diff = v - b[p];
      b[p] = v;
      for (int j = 1; j <= 10; j++) update(p, j, diff);
    } else {
      scanf("%d%d%d", &l, &r, &z);
      ans = 0;
      for (int i = 1; i <= 2 * (z - 1) && l + i - 1 <= r; i++) {
        ans += calc(2 * (z - 1), i + l - 1, r) * fz(i, z);
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
