#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
template <class Z>
inline Z SQ(Z &a) {
  return a * a;
}
template <class Z>
inline bool checkmax(Z &a, Z b) {
  if (a == -1 || a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class Z>
inline bool checkmin(Z &a, Z b) {
  if (a == -1 || a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class Z>
inline bool mymax(Z &a, Z b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class Z>
inline bool mymin(Z &a, Z b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int a[100005];
int n, m;
struct SegTree {
  long long tree[100005 << 2];
  inline void PushUp(int rt) {
    tree[rt] = tree[(rt << 1)] + tree[(rt << 1 | 1)];
  }
  void build(int s, int z, int l, int r, int rt) {
    if (l == r) {
      long long v = a[l];
      int tt = (l + s) % (2 * z - 2);
      if (tt == 0)
        tree[rt] = v * 2;
      else if (tt <= z)
        tree[rt] = v * tt;
      else
        tree[rt] = v * (2 * z - tt);
      return;
    }
    int m = (l + r) >> 1;
    build(s, z, l, m, rt << 1);
    build(s, z, m + 1, r, rt << 1 | 1);
    PushUp(rt);
  }
  void update(int s, int z, long long val, int x, int l, int r, int rt) {
    if (l == r) {
      int tt = (x + s) % (2 * z - 2);
      if (tt == 0)
        tree[rt] = val * 2;
      else if (tt <= z)
        tree[rt] = val * tt;
      else
        tree[rt] = val * (2 * z - tt);
      return;
    }
    int m = (l + r) >> 1;
    if (x <= m)
      update(s, z, val, x, l, m, rt << 1);
    else
      update(s, z, val, x, m + 1, r, rt << 1 | 1);
    PushUp(rt);
  }
  long long query(int ll, int rr, int l, int r, int rt) {
    if (ll <= l && r <= rr) {
      return tree[rt];
    }
    long long sum = 0;
    int m = (l + r) >> 1;
    if (ll <= m) sum += query(ll, rr, l, m, rt << 1);
    if (rr > m) sum += query(ll, rr, m + 1, r, rt << 1 | 1);
    return sum;
  }
} tree[4][8], t6[10];
void input() {
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
}
void build() {
  for (int z = 2; z <= 5; z++) {
    for (int i = 0; i < 2 * z - 2; i++) {
      tree[z - 2][i].build(i, z, 1, n, 1);
    }
  }
  for (int i = 0; i < 10; i++) {
    t6[i].build(i, 6, 1, n, 1);
  }
}
void gao() {
  scanf("%d", &m);
  while (m--) {
    int op;
    scanf("%d", &op);
    if (op == 1) {
      int p, v;
      scanf("%d%d", &p, &v);
      for (int z = 2; z <= 5; z++) {
        for (int i = 0; i < 2 * z - 2; i++) {
          tree[z - 2][i].update(i, z, v, p, 1, n, 1);
        }
      }
      for (int i = 0; i < 10; i++) {
        t6[i].update(i, 6, v, p, 1, n, 1);
      }
    } else {
      int l, r, z;
      scanf("%d%d%d", &l, &r, &z);
      int tp = l % (2 * z - 2);
      if (tp == 0) tp = 2 * z - 2;
      int s = (2 * z - 2) - tp + 1;
      s %= (2 * z - 2);
      if (z == 6)
        printf("%I64d\n", t6[s].query(l, r, 1, n, 1));
      else
        printf("%I64d\n", tree[z - 2][s].query(l, r, 1, n, 1));
    }
  }
}
int main() {
  while (~scanf("%d", &n)) {
    input();
    build();
    gao();
  }
}
