#include <bits/stdc++.h>
using namespace std;
int n, m;
long long zz[7][100035];
long long a[100005], b[7][12][100005];
inline int add(int ii, int jj, int kk, long long val) {
  while (kk <= n) {
    b[ii][jj][kk] += val;
    kk += (kk & (-kk));
  }
  return 0;
}
inline long long ask(int ii, int jj, int kk) {
  long long res = 0;
  while (kk > 0) {
    res += b[ii][jj][kk];
    kk -= (kk & (-kk));
  }
  return res;
}
inline int print() {
  for (int i = 2; i <= 6; i++) {
    for (int j = 1; j <= 2 * (i - 1); j++) {
      cout << "i=" << i << ",j=" << j << ":";
      for (int k = 1; k <= n; k++) {
        cout << ask(i, j, k) - ask(i, j, k - 1) << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
int main() {
  for (int i = 2; i <= 6; i++) {
    for (int j = 1; j <= 100020; j++) {
      int tmp = j % (2 * (i - 1));
      if (tmp == 0)
        zz[i][j] = 2;
      else if (tmp > 0 && tmp <= i)
        zz[i][j] = tmp;
      else
        zz[i][j] = 2 * i - tmp;
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 2; i <= 6; i++) {
    for (int j = 1; j <= 2 * (i - 1); j++) {
      for (int k = 0; k <= n; k++) {
        b[i][j][k] = 0;
      }
    }
  }
  for (int i = 2; i <= 6; i++) {
    for (int j = 1; j <= 2 * (i - 1); j++) {
      for (int k = 1, p = 1; k <= n; k++, p++) {
        add(i, j, k, a[k] * zz[i][p + j - 1]);
      }
    }
  }
  cin >> m;
  int t, p, v, l, r, z;
  for (int i = 0; i < m; i++) {
    cin >> t;
    if (t == 1) {
      cin >> p >> v;
      long long tmp = a[p];
      a[p] = v;
      for (int i = 2; i <= 6; i++) {
        for (int j = 1; j <= 2 * (i - 1); j++) {
          long long ne = (a[p] - tmp) * zz[i][p + j - 1];
          add(i, j, p, ne);
        }
      }
    } else {
      cin >> l >> r >> z;
      int jj = (2 * (z - 1)) + 1 - ((l - 1) % (2 * (z - 1)));
      if (jj > (2 * (z - 1))) jj -= (2 * (z - 1));
      long long rr = ask(z, jj, r);
      long long ll = ask(z, jj, l - 1);
      cout << rr - ll << endl;
    }
  }
  return 0;
}
