#include <bits/stdc++.h>
using namespace std;
long long tree[12][5][100001];
int n, a[100001], m, s[12][5][100001];
inline int lowbit(int x) { return x & (-x); }
inline void add(long long *c, int p, long long v) {
  for (int i = p; i <= n; i += lowbit(i)) c[i] += v;
}
inline long long sum(long long *c, int p) {
  long long re = 0;
  for (int i = p; i; i -= lowbit(i)) re += c[i];
  return re;
}
inline int gets(int l, int i, int z) {
  i += 2 * z - 2;
  int q = (i - l + 1) % (2 * z - 2);
  if (q == 0) return 2;
  if (q < z) return q;
  return 2 * z - q;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  scanf("%d", &m);
  for (int j = 2; j <= 6; ++j)
    for (int k = 0; k < j * 2 - 2; ++k)
      for (int i = 1; i <= n; ++i) {
        s[k][j - 2][i] = gets(k, i, j);
        add(tree[k][j - 2], i, (long long)(s[k][j - 2][i]) * a[i]);
      }
  for (; m--;) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int p, v;
      scanf("%d %d", &p, &v);
      for (int i = 2; i <= 6; ++i)
        for (int j = 0; j < i * 2 - 2; ++j)
          add(tree[j][i - 2], p, (long long)(v - a[p]) * s[j][i - 2][p]);
      a[p] = v;
    } else {
      int l, r, z;
      scanf("%d %d %d", &l, &r, &z);
      printf("%I64d\n", sum(tree[l % (2 * z - 2)][z - 2], r) -
                            sum(tree[l % (2 * z - 2)][z - 2], l - 1));
    }
  }
  return 0;
}
