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



import java.io.BufferedReader;

public class Main{
	public static void main(String[] args) throws IOException, InterruptedException {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int N = 1;
		while(n > N) N<<=1;
		
		long[] a = new long[N+1];
		Arrays.fill(a, (long) 1e18);
		
		for (int i = 1; i <= n; i++) {
			a[i] = sc.nextInt(); 
		}
		
		st tree = new st(a);
		
		int m = sc.nextInt();
		
		
		for (int i = 0; i < m; i++) {
			String[] q = sc.nextLine().split(" ");
			
			if (q.length == 2) 
				out.println(tree.query(Integer.parseInt(q[0])+1, Integer.parseInt(q[1])+1));
			else {
				tree.updateRange(Integer.parseInt(q[0])+1, Integer.parseInt(q[1])+1, Integer.parseInt(q[2]));
			}
			
		}
		
		out.flush();
	}

	
}

 class st{
	 
	int N;
	long[] val;
	long[] tree;
	long[] lazy;
	
	st(long[] v){
		val = v;
		tree = new long[2*(N = v.length-1)];
		Arrays.fill(tree, (long) 1e18);
		lazy = new long[2*N];
		build(1, 1, N);
	}
	
	void build(int i,int lt,int rt) {
		if (lt == rt) {
			tree[i] = val[lt]; 
		}
		
		else {
			int mid = (lt+rt)/2;
			
			build(2*i, lt,mid);
			build(2*i+1, mid+1, rt);
			
			tree[i] = Math.min(tree[2*i] , tree[2*i+1]);  
		}
	}
	
	void update(int i,int v) {
		i += N-1;
		
		tree[i] += v;
		
		while (i > 1) {
			i>>=1;
			
			tree[i] = tree[2*i] + tree[2*i+1]; 
		}
	}
	
	void updateRange(int l,int r,int v) {
		if (l > r) {
			updateRange(1, l, N, 1, N, v);
			updateRange(1, 1, r, 1, N, v);
			return;
		}
		updateRange(1, l, r, 1, N, v);
	}
	void updateRange(int i, int l,int r,int tl,int tr,int v) {
		
		if (tr < l || tl > r) 
			return;
		
		if (tl >= l && tr<= r) {
			tree[i] += v;
			lazy[i] += v; 
			return;
		}
		
		int mid = (tl+tr)/2;
		
		propagate(i, tl, mid, tr);
		
		updateRange(2*i, l, r, tl, mid, v);
		updateRange(2*i+1, l, r, mid+1, tr, v);
		
		tree[i] = Math.min(tree[2*i], tree[2*i+1]); 
		
	}
	
	void propagate(int i,int tl,int mid, int tr) {
		lazy[2*i] += lazy[i];
		lazy[2*i+1] += lazy[i];
		
		tree[2*i] += lazy[i];
		tree[2*i+1] += lazy[i];
		
		lazy[i] = 0; 
	}
	
	
	
	
	long query(int l,int r) {
		if (l > r) {
			return Math.min(query(l, N), query(1, r));
		}
		return query(1, l, r,1,N);
		
	}
	long query(int i, int l,int r,int tl,int tr) {
		
		if (l > tr || r < tl) {
			return (long) 1e18;
		}
		
		if (r >= tr && l <= tl) {
			return tree[i];
		}
		
		int mid = (tl+tr)/2;
		
		propagate(i, tl, mid, tr);
		
		long q1 = query(2*i,l,r,tl,mid);
		long q2 = query(2*i+1,l,r,mid+1,tr);
		
		return Math.min(q1,q2);
		
	}

}
	
class Scanner {
	StringTokenizer st;
	BufferedReader br;

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

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}


}

