#include <bits/stdc++.h>
using namespace std;
template <typename T, size_t size>
class SegmentTree {
  size_t pow2;
  T* tree;

 public:
  SegmentTree() {
    for (pow2 = 1; pow2 < size; pow2 <<= 1) continue;
    tree = new T[pow2 << 1];
  }
  template <class UnaryFunction>
  void push(int p, const T& x, UnaryFunction func) {
    for (tree[p += pow2] = x; p > 1; p >>= 1)
      tree[p >> 1] = func(tree[p], tree[p ^ 1]);
  }
  template <class UnaryFunction>
  T query(int l, int r, UnaryFunction func, const T& initial = T()) {
    T res = initial;
    for (l += pow2, r += pow2; l < r; l >>= 1, r >>= 1) {
      if (l & 1) res = func(res, tree[l++]);
      if (r & 1) res = func(res, tree[--r]);
    }
    return res;
  }
};
long long SUM(const long long& x, const long long& y) { return x + y; }
const size_t MAX_N = 1e5 + 5;
SegmentTree<long long, MAX_N> segtree[7][11];
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].push(i, a * z(k + 1, j), SUM);
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, t, p, v, l, r, z, a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    modify(i, a);
  }
  cin >> m;
  while (m-- && cin >> t)
    if (t == 1) {
      cin >> p >> v;
      modify(p - 1, v);
    } else {
      cin >> l >> r >> z;
      t = 2 * z - 2;
      --l;
      cout << segtree[z][(t * 60000 - l) % t].query(l, r, SUM) << '\n';
    }
}
