#include <bits/stdc++.h>
using namespace std;
template <typename T, size_t size>
class FenwickTree {
  size_t pow2;
  T* tree;
  T SUM(int i) {
    T res = T();
    for (; i; i -= i & (-i)) res += tree[i];
    return res;
  }

 public:
  FenwickTree() {
    for (pow2 = 1; pow2 < size; pow2 <<= 1) continue;
    tree = new T[pow2];
  }
  void add(int p, const T& x) {
    for (int i = p; i <= pow2; i += i & (-i)) tree[i] += x;
  }
  T query(int l, int r) { return SUM(--r) - SUM(--l); }
};
const size_t MAX_N = 1e5 + 5;
FenwickTree<long long, MAX_N> segtree[7][11];
long long arr[MAX_N];
inline long long z(int i, int z) {
  if (i == 2 * z - 2) return 2;
  if (i % (2 * z - 2) <= z) return i % (2 * z - 2);
  return 2 * z - i % (2 * z - 2);
}
inline void modify(int i, long long a) {
  for (int j = 2, t = 2; j <= 6; j++, t += 2)
    for (int k = 0; k < t; k++) {
      segtree[j][(k + t * 60000 - i) % t].add(i, (a - arr[i]) * z(k + 1, j));
    }
  arr[i] = a;
}
int main() {
  int n, m, t, p, v, l, r, z, a;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    modify(i, a);
  }
  scanf("%d", &m);
  while (m-- && scanf("%d", &t) == 1)
    if (t == 1) {
      scanf("%d%d", &p, &v);
      modify(p, v);
    } else {
      scanf("%d%d%d", &l, &r, &z);
      t = 2 * z - 2;
      printf("%I64d\n", segtree[z][(t * 60000 - l) % t].query(l, r + 1));
    }
}
