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.*;
import java.util.StringTokenizer;

public class CircularRmq {
    static class LazySegmentTree {
        private final long[] tree;
        private final long[] lazy;
        private int base;
        LazySegmentTree(int n) {
            base = 1;
            while (base < n)
                base *= 2;
            tree = new long[base * 2];
            lazy = new long[base * 2];
        }
        private void flush(int pos) {
            if (lazy[pos] != 0) {
                tree[pos] += lazy[pos];
                if (pos < base) {
                    lazy[2 * pos] += lazy[pos];
                    lazy[2 * pos + 1] += lazy[pos];
                }
                lazy[pos] = 0;
            }
        }
        private long rmqRec(int l, int r, int nl, int nr, int pos) {
            flush(pos);
            if (Math.max(l, nl) > Math.min(r, nr))
                return Long.MAX_VALUE;
            if (l <= nl && nr <= r)
                return tree[pos];
            int mid = (nl + nr) / 2;
            return Math.min(rmqRec(l, r, nl, mid, 2 * pos), rmqRec(l, r, mid + 1, nr, 2 * pos + 1));
        }
        public long rmq(int l, int r) {
            return rmqRec(l, r, 0, base - 1, 1);
        }
        private void incRec(int l, int r, int delta, int nl, int nr, int pos) {
            flush(pos);
            if (Math.max(l, nl) > Math.min(r, nr))
                return;
            if (l <= nl && nr <= r) {
                lazy[pos] = delta;
                flush(pos);
                return;
            }
            int mid = (nl + nr) / 2;
            incRec(l, r, delta, nl, mid, 2 * pos);
            incRec(l, r, delta, mid + 1, nr, 2 * pos + 1);
            tree[pos] = Math.min(tree[2 * pos], tree[2 * pos + 1]);
        }
        public void inc(int l, int r, int delta) {
            incRec(l, r, delta, 0, base - 1, 1);
        }
    }

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        CircularRmq.InputReader in = new CircularRmq.InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solve(in, out);
        out.close();
    }

    public static void solve(CircularRmq.InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        LazySegmentTree arr = new LazySegmentTree(n);
        for (int i = 0; i < n; i++)
            arr.inc(i, i, in.nextInt());
        int m = in.nextInt();
        while (m-- > 0) {
            String[] tokens = in.reader.readLine().split(" ");
            int l = Integer.parseInt(tokens[0]);
            int r = Integer.parseInt(tokens[1]);
            if (tokens.length == 2) {
                if (l <= r)
                    out.println(arr.rmq(l, r));
                else
                    out.println(Math.min(arr.rmq(0, r), arr.rmq(l, n - 1)));
            } else {
                int v = Integer.parseInt(tokens[2]);
                if (l <= r) {
                    arr.inc(l, r, v);
                } else {
                    arr.inc(0, r, v);
                    arr.inc(l, n - 1, v);
                }
            }
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}
