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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class q5 {
	
	
	public static void main(String[] args) throws IOException {
		
		Reader.init(System.in);
		PrintWriter out=new PrintWriter(System.out);
		StringBuffer output=new StringBuffer("");
		int n=Reader.nextInt();
		long[] arr=new long[n];
		for(int i=0;i<n;i++) arr[i]=Reader.nextInt();
		Seg tree=new Seg(n,arr);
		tree.build(0, 0, n-1);
		int q=Reader.nextInt();
		while(q>0) {
			q--;
			String[] s=Reader.nextLine().split(" ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			if(s.length==2) {
				if(a<=b) {
					out.println(tree.query(0,0, n-1, a, b));
				}
				else {
					long l=Math.min(tree.query(0, 0, n-1, a, n-1), tree.query(0, 0, n-1, 0, b));
					out.println(l);
				}
			}
			else {
				int c=Integer.parseInt(s[2]);
				if(a<=b) {
					tree.u1(0, 0, n-1, a,b,c);
				}
				else {
					tree.u1(0, 0, n-1, a, n-1,c);
					tree.u1(0, 0, n-1, 0, b,c);
				}
			}
			
		}
		out.flush();
		
	}
}



class NoD{
	int a,b,c;
	
	String s;
	long ms,ls,rs,ts;
	NoD(int aa,int bb){
		a=aa;b=bb;
		s=a+" "+b;
		
	}
	NoD(int aa,int bb,int cc){
		a=aa;b=bb;c=cc;
	}
	NoD(long m,long l,long r,long t){
		ms=m;ls=l;rs=r;ts=t;
	}
	@Override
	public boolean equals(Object o) {
		if(o!=null && o.getClass()==getClass()) {
			NoD c= (NoD) o;
			return c.a==a && c.b==b;
		}
		return false;
	}
	@Override
	public int hashCode() {
		return s.hashCode();
	}
}

class Seg{
	long[] st;
	long[] arr;
	long[] lazy;
	Seg(int n,long[] a){
		st=new long[4*n];
		arr=a;
		lazy=new long[4*n];
		
	}
	void build(int index,int low,int high) {
		if(low==high) {
			st[index]=arr[low];
		}
		else {
			int middle=(low+high)/2;
			build(2*index+1,low,middle);
			build(2*index+2,middle+1,high);
			st[index]=Math.min(st[2*index+1], st[2*index+2]);
		}
	}
	
	long query(int index,int low,int high, int ql,int qh) {
		if(lazy[index]!=0) {
			st[index]+=lazy[index];
			if(low<high) {
				lazy[2*index+1]+=lazy[index];
				lazy[2*index+2]+=lazy[index];
				
			}
			lazy[index]=0;
		}
		
		if(ql<=low && high<=qh) {
			return st[index];
		}
		else if(!(ql>high || qh<low)) {
			int middle=(low+high)/2;
			long left=query(2*index+1,low,middle,ql,qh);
			long right=query(2*index+2,middle+1,high,ql,qh);
			st[index]=Math.min(st[2*index+1], st[2*index+2]);
			return Math.min(left,right);
			
		}
		return Long.MAX_VALUE;
	}
	
	
	void u1(int index, int low,int high, int ql, int qh,long c) {
		if(lazy[index]!=0) {
			st[index]+=lazy[index];
			if(low<high) {
				lazy[2*index+1]+=lazy[index];
				lazy[2*index+2]+=lazy[index];
				
			}
			lazy[index]=0;
		}
		if(ql<=low && high<=qh) {
			st[index]+=c;
			if(low<high) {
				lazy[2*index+1]+=c;lazy[2*index+2]+=c;
			}
		}
		else if(!(qh<low || ql>high)) {
			int middle=(low+high)/2;
			u1(2*index+1,low,middle,ql,qh,c);
			u1(2*index+2,middle+1,high,ql,qh,c);
			st[index]=Math.min(st[2*index+1], st[2*index+2]);
		}
	}
	
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String nextLine() throws IOException{
    	return reader.readLine();
    }
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }
    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}