#include <bits/stdc++.h>
using namespace std;
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = c - 48;
  while (c = getchar(), c >= '0' && c <= '9') X = X * 10 + c - 48;
  return X;
}
void Output(long long X) {
  int Data[20], Len = 0;
  while (X) {
    Data[Len++] = X % 10;
    X /= 10;
  }
  if (!Len) Data[Len++] = 0;
  while (Len--) putchar(Data[Len] + 48);
  putchar('\n');
}
const int Code[11][10] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  0,  0,  0,  1,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  0,  0,  2,  3,  4,  5,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  0,  0,  6,  7,  8,  9,  10, 11,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0,  12, 13, 14, 15, 16, 17, 18, 19,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
};
int N;
long long S[30][100001];
void Add(int X, int P, long long Delta) {
  while (P <= N) {
    S[X][P] += Delta;
    P += P & -P;
  }
}
long long Sum(int X, int P) {
  long long Ans = 0;
  while (P) {
    Ans += S[X][P];
    P -= P & -P;
  }
  return Ans;
}
int main() {
  static long long Data[100000];
  N = Get();
  for (int i = 0; i < N; i++) Data[i] = Get();
  memset(S, 0, sizeof(S));
  for (int i = 0; i < N; i++)
    for (int j = 2; j <= 10; j += 2) Add(Code[j][i % j], i + 1, Data[i]);
  int Query = Get();
  while (Query--) {
    int Type = Get();
    if (Type == 1) {
      int X = Get() - 1, Y = Get();
      for (int i = 2; i <= 10; i += 2) Add(Code[i][X % i], X + 1, Y - Data[X]);
      Data[X] = Y;
    } else {
      int L = Get() - 1, R = Get(), M = (Get() - 1) * 2;
      long long Ans = 0;
      for (int i = 0, j = 1; i < M; i++, j++) {
        int X = Code[M][(L + i) % M];
        Ans += (Sum(X, R) - Sum(X, L)) * min(j, M + 2 - j);
      }
      Output(Ans);
    }
  }
  return 0;
}
