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
/*
	http://codeforces.com/problemset/problem/52/C
*/

import java.io.*;
import java.util.*;

public class Main{
	public static void main(String arg[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String inp[] = br.readLine().split(" ");
		int arr[] = new int[inp.length];
		for(int i=0;i<inp.length;i++){
			arr[i] = Integer.parseInt(inp[i]);
		}

		SimpleSegmentTreeForCircularRMQ tree = new SimpleSegmentTreeForCircularRMQ(n,arr);

		//System.out.println("");
		//System.out.println(Arrays.toString(tree.min));
		//System.out.println(Arrays.toString(tree.low));
		//System.out.println(Arrays.toString(tree.high));
		//System.out.println(Arrays.toString(tree.initialState));

		int t = Integer.parseInt(br.readLine());
		while(t-->0){
			inp = br.readLine().split(" ");
			if(inp.length == 2){
				int left = Integer.parseInt(inp[0]);
				int right = Integer.parseInt(inp[1]);
				if(left <= right){
					System.out.println(tree.minimum(left,right));
				}else{
					int minOne = tree.minimum(left,n-1);
					int minTwo = tree.minimum(0,right);
					//System.out.println(minOne + " " + minTwo);
					System.out.println(Math.min(minOne,minTwo));
				}

			}else{
				int left = Integer.parseInt(inp[0]);
				int right = Integer.parseInt(inp[1]);
				int val = Integer.parseInt(inp[2]);;
				if(left <= right){
					tree.increment(left,right,val);
				}else{
					tree.increment(left,n-1,val);
					tree.increment(0,right,val);
				} 
			}
		}
	}
}

interface QueryInterfaceForCircularRMQ{
	public void increment(int i, int j, int val);
	public int minimum(int i, int j);
}

class SimpleSegmentTreeForCircularRMQ implements QueryInterfaceForCircularRMQ{

	int n;//Number of elements

	int[] low,high,min,delta;

	int[] initialState;

	public SimpleSegmentTreeForCircularRMQ(int n, int[] initialState){
		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];

		this.initialState = initialState;

		init(1,0,n-1);

		//System.out.println(Arrays.toString(min));
	}

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

		if(a==b){//Leaf Node
			min[i] = initialState[a];
			int ii = i/2;
			while(ii > 0){
				update(ii);
				ii /= 2;
			}
			return;
		}

		int mid = (a+b)/2;

		init(2*i,a,mid);
		init(2*i+1,mid+1,b);
	}

	void prop(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]);
		//System.out.println(min[i]);
	}

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

	public void increment(int i, int a, int b, int val){
		if(high[i] < a || low[i] > b){//Outside case
			return;
		}
		if(a <= low[i] && b >= high[i]){
			delta[i] += val;
			return;
		}
		//Partial Case
		prop(i);

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

		update(i);

	}

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

	public int minimum(int i, int a, int b){
		if(a > high[i] || b < low[i]){
			return Integer.MAX_VALUE;
		}
		if(a <= low[i] && b >= high[i]){
			return min[i] + delta[i];
		}
		prop(i);

		//System.out.println("i - min " + i);

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

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

