#include <bits/stdc++.h>
using namespace std;
class FenwickTree {
 public:
  long long sum(int r) {
    long long result = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r];
    return result;
  }
  long long sum(int l, int r) { return sum(r) - sum(l - 1); }
  void inc(int i, long long delta) {
    for (; i < (int)t.size(); i = (i | (i + 1))) t[i] += delta;
  }
  void inc(int l, int r, long long delta) {
    inc(l, delta);
    inc(r + 1, -delta);
  }
  void assign(int i, long long value) {
    long long delta = value - sum(i, i);
    inc(i, delta);
  }
  FenwickTree(std::vector<long long> &a) : t(vector<long long>(a.size(), 0)) {
    for (int i = 0; i < (int)a.size(); ++i) inc(i, a[i]);
  }
  FenwickTree() {}

 private:
  std::vector<long long> t;
};
int zigzag(int i, int z) {
  int zz = 2 * (z - 1);
  if (i % zz == 0) return 2;
  if (i % zz <= z) return i % zz;
  return z * 2 - i % zz;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n;
  vector<vector<vector<int> > > zagzagz(7);
  for (int i = 2; i <= 6; ++i) {
    zagzagz[i] = vector<vector<int> >((i - 1) * 2, vector<int>(n + 1));
    for (int j = 0; j < (i - 1) * 2; ++j) {
      for (int k = 1; k <= n; ++k) {
        zagzagz[i][j][k] = zigzag(k + j, i);
      }
    }
  }
  vector<long long> a(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  vector<vector<FenwickTree> > trees(7);
  for (int i = 2; i <= 6; ++i) {
    trees[i] = vector<FenwickTree>((i - 1) * 2);
    for (int j = 0; j < (i - 1) * 2; ++j) {
      vector<long long> aij(a);
      for (int k = 1; k <= n; ++k) aij[k] = a[k] * zagzagz[i][j][k];
      trees[i][j] = FenwickTree(aij);
    }
  }
  cin >> m;
  int t, x, y, z;
  while (m--) {
    cin >> t;
    if (t == 1) {
      cin >> x >> y;
      for (int i = 2; i <= 6; ++i)
        for (int j = 0; j < (i - 1) * 2; ++j)
          trees[i][j].assign(x, (long long)y * zagzagz[i][j][x]);
    } else {
      cin >> x >> y >> z;
      int mod = x % ((z - 1) * 2);
      if (mod == 0) mod += (z - 1) * 2;
      int pos = (z - 1) * 2 + 1 - mod;
      pos %= (z - 1) * 2;
      cout << trees[z][pos].sum(x, y) << '\n';
    }
  }
  return 0;
}
