import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: Niyaz Nigmatullin
 * Date: 11/16/13
 * Time: 12:01 AM
 * To change this template use File | Settings | File Templates.
 */
public class hel_nn {

    static class SegmentTree {
        int[] minimal;
        int[] maximal;
        long[] sum;
        int n;

        SegmentTree(int n) {
            this.n = Integer.highestOneBit(n) << 1;
            minimal = new int[this.n * 2];
            maximal = new int[this.n * 2];
            sum = new long[this.n * 2];
            Arrays.fill(minimal, Integer.MAX_VALUE);
            Arrays.fill(maximal, Integer.MIN_VALUE);
        }

        void set(int x, int y) {
            x += n;
            sum[x] = y;
            minimal[x] = y;
            maximal[x] = y;
            while (x > 1) {
                x >>= 1;
                minimal[x] = Math.min(minimal[x * 2], minimal[x * 2 + 1]);
                maximal[x] = Math.max(maximal[x * 2], maximal[x * 2 + 1]);
                sum[x] = sum[x * 2] + sum[x * 2 + 1];
            }
        }

        int getMin(int l, int r) {
            --r;
            l += n;
            r += n;
            int ret = Integer.MAX_VALUE;
            while (l <= r) {
                if ((l & 1) == 1) {
                    ret = Math.min(ret, minimal[l++]);
                }
                if ((r & 1) == 0) {
                    ret = Math.min(ret, minimal[r--]);
                }
                l >>= 1;
                r >>= 1;
            }
            return ret;
        }

        int getMax(int l, int r) {
            --r;
            l += n;
            r += n;
            int ret = Integer.MIN_VALUE;
            while (l <= r) {
                if ((l & 1) == 1) {
                    ret = Math.max(ret, maximal[l++]);
                }
                if ((r & 1) == 0) {
                    ret = Math.max(ret, maximal[r--]);
                }
                l >>= 1;
                r >>= 1;
            }
            return ret;
        }

        long getSum(int l, int r) {
            --r;
            l += n;
            r += n;
            long ret = 0;
            while (l <= r) {
                if ((l & 1) == 1) {
                    ret += sum[l++];
                }
                if ((r & 1) == 0) {
                    ret += sum[r--];
                }
                l >>= 1;
                r >>= 1;
            }
            return ret;
        }
    }

    static void solve() throws IOException {
        int n = nextInt();
        SegmentTree tree = new SegmentTree(n);
        for (int i = 0; i < n; i++) {
            tree.set(i, nextInt());
        }
        int m = nextInt();
        for (int i = 0; i < m; i++) {
            String s = next();
            if (s.equals("assign")) {
                tree.set(nextInt() - 1, nextInt());
            } else {
                int l = nextInt() - 1;
                int r = nextInt();
                long k = nextInt() - 1;
                out.println(tree.getSum(l, r) + k * (k < 0 ? tree.getMin(l, r) : tree.getMax(l, r)));
            }
        }
    }

    static StringTokenizer tokenizer;
    static BufferedReader reader;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new FileReader("hel.in"));
        out = new PrintWriter("hel.out");
        solve();
        out.close();
        reader.close();
    }

    static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = reader.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}
