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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class CCircularRMQ {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt(), N = 1;
            while (N < n)
                N <<= 1;
            long[] arrrr = new long[N + 1];
            for (int i = 1; i <= n; i++)
                arrrr[i] = sc.nextInt();
            CCircularRMQ.SegmentTree st = new CCircularRMQ.SegmentTree(arrrr);
            int q = sc.nextInt();
            while (q-- > 0) {
                StringTokenizer tt = new StringTokenizer(sc.nextLine());
                if (tt.countTokens() == 2) {
                    int l = Integer.parseInt(tt.nextToken()) + 1, r = Integer.parseInt(tt.nextToken()) + 1;
                    if (l <= r)
                        pw.println(st.query(l, r));
                    else {
                        pw.println(Math.min(st.query(l, n), st.query(1, r)));
                    }
                } else {
                    int l = Integer.parseInt(tt.nextToken()) + 1, r = Integer.parseInt(tt.nextToken()) + 1, v = Integer.parseInt(tt.nextToken());
                    if (l <= r)
                        st.update_range(l, r, v);
                    else {
                        st.update_range(l, n, v);
                        st.update_range(0, r, v);
                    }
                }
            }
        }

        static public class SegmentTree {
            int N;
            long[] array;
            long[] sTree;
            long[] lazy;

            SegmentTree(long[] in) {
                array = in;
                N = in.length - 1;
                sTree = new long[N << 1];        //no. of nodes = 2*N - 1, we add one to cross out index zero
                lazy = new long[N << 1];
                build(1, 1, N);
            }

            void build(int node, int b, int e) {
                if (b == e)
                    sTree[node] = array[b];
                else {
                    int mid = b + e >> 1;
                    build(node << 1, b, mid);
                    build(node << 1 | 1, mid + 1, e);
                    sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);
                }
            }

            void update_range(int i, int j, int val) {
                update_range(1, 1, N, i, j, val);
            }

            void update_range(int node, int b, int e, int i, int j, int val) {
                if (i > e || j < b)
                    return;
                if (b >= i && e <= j) {
                    sTree[node] += val;
                    lazy[node] += val;
                } else {
                    int mid = b + e >> 1;
                    propagate(node, b, mid, e);
                    update_range(node << 1, b, mid, i, j, val);
                    update_range(node << 1 | 1, mid + 1, e, i, j, val);
                    sTree[node] = Math.min(sTree[node << 1], sTree[node << 1 | 1]);
                }

            }

            void propagate(int node, int b, int mid, int e) {
                lazy[node << 1] += lazy[node];
                lazy[node << 1 | 1] += lazy[node];
                sTree[node << 1] += lazy[node];
                sTree[node << 1 | 1] += lazy[node];
                lazy[node] = 0;
            }

            long query(int i, int j) {
                return query(1, 1, N, i, j);
            }

            long query(int node, int b, int e, int i, int j) {
                if (i > e || j < b)
                    return Long.MAX_VALUE;
                if (b >= i && e <= j)
                    return sTree[node];
                int mid = b + e >> 1;
                propagate(node, b, mid, e);
                long q1 = query(node << 1, b, mid, i, j);
                long q2 = query(node << 1 | 1, mid + 1, e, i, j);
                return Math.min(q1, q2);
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

        public String nextLine() {
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

    }
}

