#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
const int MAX_E2 = 1 << 18;
const int MIN_Z = 2;
const int MAX_Z = 6;
const int Y = MAX_Z - MIN_Z + 1;
const int MIN_Z2 = 2 * (MIN_Z - 1);
const int MAX_Z2 = 2 * (MAX_Z - 1);
struct Elm {
  long long ss[Y][MAX_Z2];
  Elm() {}
  void add(int i, long long v) {
    for (int y = 0, z2 = MIN_Z2; z2 <= MAX_Z2; y++, z2 += 2) ss[y][i % z2] += v;
  }
  Elm operator+(const Elm &e) const {
    Elm r;
    for (int y = 0, z2 = MIN_Z2; z2 <= MAX_Z2; y++, z2 += 2)
      for (int j = 0; j < z2; j++) r.ss[y][j] = ss[y][j] + e.ss[y][j];
    return r;
  }
  void print() {
    for (int y = 0, z2 = MIN_Z2; z2 <= MAX_Z2; y++, z2 += 2) {
      printf("%d", z2 / 2 + 1);
      for (int j = 0; j < z2; j++) printf(" %lld", ss[y][j]);
      putchar('\n');
    }
  }
};
template <typename T, const int MAX_E2>
struct SegTree {
  int n, e2;
  T nodes[MAX_E2], zero;
  SegTree() {}
  void init(int _n) {
    n = _n;
    memset(&zero, 0, sizeof(zero));
    for (e2 = 1; e2 < n; e2 <<= 1)
      ;
  }
  T &get(int i) { return nodes[e2 - 1 + i]; }
  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
    }
  }
  void setall() {
    for (int j = e2 - 2; j >= 0; j--)
      nodes[j] = nodes[j * 2 + 1] + nodes[j * 2 + 2];
  }
  T sum_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return zero;
    if (r0 <= i0 && i1 <= r1) return nodes[k];
    int im = (i0 + i1) / 2;
    T v0 = sum_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = sum_range(r0, r1, k * 2 + 2, im, i1);
    return v0 + v1;
  }
  T sum_range(int r0, int r1) { return sum_range(r0, r1, 0, 0, e2); }
};
int as[MAX_N];
SegTree<Elm, MAX_E2> st;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  st.init(n);
  for (int i = 0; i < n; i++) st.get(i).add(i, as[i]);
  st.setall();
  int m;
  scanf("%d", &m);
  while (m--) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int p, v;
      scanf("%d%d", &p, &v);
      p--;
      Elm e = st.get(p);
      e.add(p, v - as[p]);
      st.set(p, e);
      as[p] = v;
    } else {
      int l, r, z;
      scanf("%d%d%d", &l, &r, &z);
      l--;
      Elm e = st.sum_range(l, r);
      int z2 = 2 * (z - 1);
      long long sum = 0;
      for (int i = 0; i < z2; i++) {
        int szi = ((i < z - 1) ? i : z2 - i) + 1;
        sum += e.ss[z - 2][(i + l) % z2] * szi;
      }
      printf("%lld\n", sum);
    }
  }
  return 0;
}
