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

//Visca Barca
import java.util.*;
import java.io.*;
import java.math.*;
public class Main implements Runnable
{
    @Override
    public void run() {

    }
    public static long [] lazy;
    static class FastReader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public FastReader() { this(System.in); }public FastReader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String next(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){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 - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){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 - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(next()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public void scanIntArr(int [] arr){ for(int li=0;li<arr.length;++li){ arr[li]=i();}}
        public void scanLongArr(long [] arr){for (int i=0;i<arr.length;++i){arr[i]=l();}}
        public void shuffle(int [] arr){ for(int i=arr.length;i>0;--i) { int r=(int)(Math.random()*i); int temp=arr[i-1]; arr[i-1]=arr[r]; arr[r]=temp; } }
    }
    public static void main(String[] args)throws IOException {
        // new Thread(null,new Main(),"Anything",1<<27).start();
        FastReader fr=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
              /*
inputCopy
4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1
outputCopy
1
0
0

6
-100000 500 10 -1100 1200 1600
4
4 0
0 5
2 4 1100
2 4
-100000
-100000
0
        */
        int n=fr.i();
        int [] arr=new int[n];
        long [] segTree=new long[4*n];
        lazy=new long[4*n];
        fr.scanIntArr(arr);
        build(segTree,arr,0,n-1,0);
        //-System.err.println(Arrays.toString(segTree));
        int m=fr.i();
        for(int mi=0;mi<m;++mi)
        {
            StringTokenizer st=new StringTokenizer(fr.nextLine());
            int num1=Integer.parseInt(st.nextToken());
            int num2=Integer.parseInt(st.nextToken());
            if(st.hasMoreTokens())
            {
                if(num1<=num2)
                {
                    int l=num1;int r=num2;
                    int v=Integer.parseInt(st.nextToken());
                    update(segTree,l,r,0,n-1,0,v);
                    //System.err.println(Arrays.toString(segTree));
                }
                else
                {
                    int l=num1;
                    int r=n-1;
                    int v=Integer.parseInt(st.nextToken());
                    update(segTree,l,r,0,n-1,0,v);
                    //System.err.println(Arrays.toString(segTree));

                    l=0;
                    r=num2;
                    update(segTree,l,r,0,n-1,0,v);
                    //System.err.println(Arrays.toString(segTree));
                }
            }
            else
            {
                if(num1<=num2) {
                    int l = num1;
                    int r = num2;
                    pw.println(query(segTree,l,r,0,n-1,0));
                }
                else
                {
                    int l=num1;
                    int r=n-1;
                    pw.println(Math.min(query(segTree,num1,n-1,0,n-1,0),query(segTree,0,num2,0,n-1,0)));
                }
            }
        }
        pw.flush();
        pw.close();
    }
    public static long query(long [] segTree,int l,int r,int curL,int curR,int curIndex)
    {

        if(curR<l || curL>r)
            return Long.MAX_VALUE;
        
        if(lazy[curIndex]!=0)
        {
            segTree[curIndex]+=lazy[curIndex];
            if(curL!=curR)
            {
                lazy[2*curIndex+1]+=lazy[curIndex];
                lazy[2*curIndex+2]+=lazy[curIndex];
            }
            lazy[curIndex]=0;
        }
        

        if(l<=curL && r>=curR)
        {
            return segTree[curIndex];
        }
        int mid=(curL+curR)/2;
        return Math.min(query(segTree,l,r,curL,mid,2*curIndex+1),query(segTree,l,r,mid+1,curR,2*curIndex+2));
    }
    public static void update(long [] segTree,int l,int r,int curL,int curR,int curIndex,int v)
    {
        if(lazy[curIndex]!=0)
        {
            segTree[curIndex]+=lazy[curIndex];
            if(curL!=curR)
            {
                lazy[2*curIndex+1]+=lazy[curIndex];
                lazy[2*curIndex+2]+=lazy[curIndex];
            }
            lazy[curIndex]=0;
        }
        if(curR<l || curL>r)
        {
            return;
        }

        int mid=(curL+curR)/2;
        if(curL>=l && curR<=r)
        {
            segTree[curIndex]+=v;
            if(curL!=curR)
            {
                lazy[2*curIndex+1]+=v;
                lazy[2*curIndex+2]+=v;
            }
            //update(segTree,l,r,curL,mid,2*curIndex+1,v);
            //update(segTree,l,r,mid+1,curR,2*curIndex+2,v);
            return;
        }
        update(segTree,l,r,curL,mid,2*curIndex+1,v);
        update(segTree,l,r,mid+1,curR,2*curIndex+2,v);
        segTree[curIndex]=Math.min(segTree[2*curIndex+1],segTree[2*curIndex+2]);
    }
    public static void build(long [] segTree,int [] arr,int l,int r,int curIndex)
    {
        if(l==r)
        {
            segTree[curIndex]=arr[l];
            return;
        }
        int mid=(l+r)/2;
        build(segTree,arr,l,mid,2*curIndex+1);
        build(segTree,arr,mid+1,r,2*curIndex+2);
        segTree[curIndex]=Math.min(segTree[2*curIndex+1],segTree[2*curIndex+2]);
    }
}
