You are given circular array a0, a1, ..., an - 1. There are two types of operations with it: 

  * inc(lf, rg, v) — this operation increases each element on the segment [lf, rg] (inclusively) by v; 
  * rmq(lf, rg) — this operation returns minimal value on the segment [lf, rg] (inclusively). 



Assume segments to be circular, so if n = 5 and lf = 3, rg = 1, it means the index sequence: 3, 4, 0, 1.

Write program to process given sequence of operations.

Input

The first line contains integer n (1 ≤ n ≤ 200000). The next line contains initial state of the array: a0, a1, ..., an - 1 ( - 106 ≤ ai ≤ 106), ai are integer. The third line contains integer m (0 ≤ m ≤ 200000), m — the number of operartons. Next m lines contain one operation each. If line contains two integer lf, rg (0 ≤ lf, rg ≤ n - 1) it means rmq operation, it contains three integers lf, rg, v (0 ≤ lf, rg ≤ n - 1; - 106 ≤ v ≤ 106) — inc operation.

Output

For each rmq operation write result for it. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1


Output

1
0
0
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskC {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        long[] data = in.nextLongArray();
        SegmentTree tree = new SegmentTree(data);
        int m = in.nextInt();
        for (int _ = 0; _ < m; _++) {
            String[] line = in.nextLine().split(" ");
            if (line.length == 2) {
                out.println(tree.requestOnRange(Integer.parseInt(line[0]), Integer.parseInt(line[1])));
            } else {
                tree.changeOnRange(Integer.parseInt(line[0]), Integer.parseInt(line[1]),Integer.parseInt(line[2]));
            }
        }
    }
}

class SegmentTree {
    private final int H, M, size;
    private final long[] data, tag;

    SegmentTree(int size) {
        this.size = size;
        int tmpH = 0;
        while ((1 << tmpH) < size + 2) {
            tmpH++;
        }
        H = tmpH;
        M = 1 << H;
        data = new long[M << 1];
        tag = new long[M << 1];
    }

    SegmentTree(long[] _data) {
        this(_data.length);
        System.arraycopy(_data, 0, this.data, M + 1, size);
        for (int i = M - 1; i >= 1; i--) {
            data[i] = Math.min(data[i + i], data[i + i + 1]);
        }
    }

    void addNewChange(int index, long delta) {
        data[index] += delta;
        tag[index] += delta;
    }

    void pushToSon(int index) {
        if (index < M) {
            addNewChange(index + index, tag[index]);
            addNewChange(index + index + 1, tag[index]);
            tag[index] = 0;
        }
    }

    void pushToLeaf(int index) {
        for (int i = H; i >= 1; i--) {
            pushToSon(index >> i);
        }
    }

    private void changeOnRange0(int l, int r, long delta) {
        l += M - 1;
        r += M + 1;
        pushToLeaf(l);
        pushToLeaf(r);

        int l0 = l, r0 = r;
        while (r - l > 1) {
            if ((l & 1) == 0) addNewChange(l ^ 1, delta);
            if ((r & 1) == 1) addNewChange(r ^ 1, delta);
            l >>= 1;
            r >>= 1;
        }
        for (int i = 0; i < H; i++) {
            l0 >>= 1;
            r0 >>= 1;
            data[l0] = Math.min(data[l0 + l0], data[l0 + l0 + 1]);
            data[r0] = Math.min(data[r0 + r0], data[r0 + r0 + 1]);
        }
    }

    private long requestOnRange0(int l, int r) {
        l += M - 1;
        r += M + 1;
        pushToLeaf(l);
        pushToLeaf(r);

        long result = Long.MAX_VALUE;
        while (r - l > 1) {
            if ((l & 1) == 0) result = Math.min(result, data[l ^ 1]);
            if ((r & 1) == 1) result = Math.min(result, data[r ^ 1]);
            l >>= 1;
            r >>= 1;
        }
        return result;
    }

    void changeOnRange(int l, int r, long delta) {
        ++l;
        ++r;
        if (l <= r) changeOnRange0(l, r, delta);
        else {
            changeOnRange0(l, size, delta);
            changeOnRange0(1, r, delta);
        }
    }

    long requestOnRange(int l, int r) {
        ++l;
        ++r;
        if (l <= r) return requestOnRange0(l, r);
        else {
            return Math.min(requestOnRange0(l, size),
                    requestOnRange0(1, r));
        }
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String rawNextLine() {
        StringBuilder buf = new StringBuilder();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String nextLine() {
        String s = rawNextLine();
        while (s.trim().length() == 0)
            s = rawNextLine();
        return s;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long[] nextLongArray(int count) {
        long[] result = new long[count];
        for (int i = 0; i < count; i++) {
            result[i] = nextLong();
        }
        return result;
    }

    public long[] nextLongArray() {
        return nextLongArray(nextInt());
    }

}

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
//        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
        writer = new PrintWriter(stream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(long x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

}