#include <bits/stdc++.h>
using namespace std;
inline long long labs(long long a) { return a < 0 ? (-a) : a; }
template <typename T>
inline T sqr(T x) {
  return x * x;
}
const int MAXZ = 7;
const int MAXSHIFT = MAXZ * 2;
struct Fenwick {
  vector<long long> t;
  long long n;
  void init(long long nn) {
    n = nn;
    t.assign(n, 0);
  }
  long long sum(long long r) {
    long long result = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r];
    return result;
  }
  void inc(long long i, long long delta) {
    for (; i < n; i = (i | (i + 1))) t[i] += delta;
  }
  long long sum(long long l, long long r) { return sum(r) - sum(l - 1); }
  void init(const vector<long long> &a) {
    init(a.size());
    for (long long i = 0; i < a.size(); i++) inc(i, a[i]);
  }
};
Fenwick f[MAXZ][MAXSHIFT];
vector<long long> v;
long long getS(long long i, long long z) {
  i++;
  if (i % (2 * (z - 1)) == 0) return 2;
  if (i % (2 * (z - 1)) <= z) return i % (2 * (z - 1));
  return 2 * z - i % (2 * (z - 1));
}
int main() {
  int n;
  cin >> n;
  v.resize(n);
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> v[i];
  }
  vector<long long> tmp;
  for (long long z = 2; z < MAXZ; z++) {
    long long msh = (z - 1) * 2;
    for (long long sh = 0; sh < msh; sh++) {
      tmp.clear();
      for (int(i) = 0; (i) < (n); (i)++) {
        tmp.push_back(getS(i - sh + msh, z) * v[i]);
      }
      f[z][sh].init(tmp);
    }
  }
  int m;
  cin >> m;
  for (int(qqq) = 0; (qqq) < (m); (qqq)++) {
    int t;
    cin >> t;
    if (t == 1) {
      long long i, a;
      cin >> i >> a;
      i--;
      for (long long z = 2; z < MAXZ; z++) {
        long long msh = (z - 1) * 2;
        for (long long sh = 0; sh < msh; sh++) {
          f[z][sh].inc(i, (a - v[i]) * getS(i - sh + msh, z));
        }
      }
      v[i] = a;
    } else {
      long long l, r, z;
      cin >> l >> r >> z;
      l--;
      r--;
      long long msh = (z - 1) * 2;
      cout << f[z][l % msh].sum(l, r) << endl;
    }
  }
  return 0;
}
