#include <cstdio>

const long long INF = 1LL << 60;
const int N = 333333;
int a[N];

int main() {
  freopen("hel.in", "r", stdin);
  freopen("hel.out", "w", stdout);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int m;
  scanf("%d", &m);
  char op[30];
  for (int i = 0; i < m; i++) {
    scanf("%s", op);
    if (op[0] == 'a') {
      int x, y;
      scanf("%d%d", &x, &y);
      a[x - 1] = y;
    } else {
      int l, r, k;
      scanf("%d%d%d", &l, &r, &k);
      --l;
      long long ans = 0;
      long long ma = -INF;
      for (int j = l; j < r; j++) {
        ans += a[j];
        long long cur = (long long) (k - 1) * a[j];
        if (ma < cur) ma = cur;
      }
      printf("%lld\n", ans + ma);
    }
  }
}
