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 {

    public static PrintWriter out;

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        int n      = sc.nextInt();
        SegmentTree tree = new SegmentTree(n);
        for(int i = 0; i < n; i++)  {
            int a = sc.nextInt();
            tree.increment(i , i, a);
        }

        int m = sc.nextInt();
        for(int i = 0; i < m; i++){
            String[] line = sc.nextLine().split(" ");

            if(line.length == 3){

                Integer l = Integer.parseInt(line[0]);
                Integer r = Integer.parseInt(line[1]);
                Integer val = Integer.parseInt(line[2]);
                if(r < l){
                    tree.increment(0, r, val);
                    tree.increment(l, n-1, val);
                }
                else{
                    tree.increment(l, r, val);
                }
            }
            else{
                Integer l = Integer.parseInt(line[0]);
                Integer r = Integer.parseInt(line[1]);
                int result;
                if (r < l) {
                    int a = tree.minimum(0, r);
                    int b = tree.minimum(l, n-1);
                    result = Math.min(a, b);
                }
                else{
                    result = tree.minimum(l, r);
                }
                out.println(result);
            }
        }
        out.close();
    }

    public static class SegmentTree{

        int n;
        int[] low, high;
        int[] min, delta;

        public SegmentTree(int n){
            this.n = n;
            low = new int[4 * n + 1];
            high = new int[4 * n + 1];
            min = new int[4 * n + 1];
            delta = new int[4 * n + 1];
            init(1, 0, n-1);
        }

        void init(int i, int a, int b){
            low[i] = a;
            high[i] = b;

            if(a == b)  return;

            int mid = a + (b - a) / 2;
            init(2 * i, a, mid);
            init(2 * i + 1, mid + 1, b);
        }

        public void increment(int a, int b, int val) {
            increment(1, a, b, val);
        }

        public int minimum(int a, int b) {
            return minimum(1, a, b);
        }

        void propogate(int i){
            delta[2 * i] += delta[i];
            delta[2 * i + 1] += delta[i];
            delta[i] = 0;
        }

        void update(int i){
            min[i] = Math.min(min[2 * i] + delta[2 * i], min[2 * i + 1] + delta[2 * i + 1]);
        }

        void increment(int i, int a, int b, int val){
            if(b < low[i] || high[i] < a)   return;

            if(a <= low[i] && high[i] <= b){
                delta[i] += val;
                return;
            }

            propogate(i);
            increment(2 * i, a, b, val);
            increment(2 * i + 1, a, b, val);

            update(i);
        }

        int minimum(int i, int a, int b){
            if(b < low[i] || high[i] < a)   return Integer.MAX_VALUE;

            if(a <= low[i] && high[i] <= b){
                return  min[i] + delta[i];
            }

            propogate(i);

            int minLeft = minimum(2 * i, a, b);
            int minRight = minimum(2 * i + 1, a, b);

            update(i);
            return Math.min(minLeft, minRight);
        }
    }

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
