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.*;

public class Segment_Tree_Object {

	public static void main(String[] args) throws Exception { new Segment_Tree_Object(); }
	
	long oo = (long) 1e18;
	
	Segment_Tree_Object() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		int n = Integer.parseInt(br.readLine());
		
		String[] split = br.readLine().split(" ");
		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(split[i]);
		}
		Node root = new Node(0, n-1, arr);
		
		int Q = Integer.parseInt(br.readLine());
		for(int qq = 0; qq < Q; qq++) {
			split = br.readLine().split(" ");
			
			int L = Integer.parseInt(split[0]);
			int R = Integer.parseInt(split[1]);
			long v1 = oo;
			if(split.length == 2) {
				if(R < L) {
					v1 = root.rmq(L, n-1);
					v1 = Math.min(v1, root.rmq(0, R));
				}
				else {
					v1 = root.rmq(L, R);
				}
				
				out.println(v1);
			}
			else {
				int v = Integer.parseInt(split[2]);
				if(R < L) {
					root.inc(L, n-1, v);
					root.inc(0, R, v);
				}
				else {
					root.inc(L, R, v);
				}
			}
			
		}
		
		out.close();
	}
	
	class Node {
		int L, R;
		long minVal, lazy;
		Node left, right;
		
		Node(int lf, int rg, int[] arr) {
			L = lf;
			R = rg;
			if(L == R) {
				minVal = arr[L];
				return;
			}
			
			int mid = (lf + rg) / 2;
			
			left = new Node(lf, mid, arr);
			right = new Node(mid+1, rg, arr);
			
			minVal = Math.min(left.minVal, right.minVal);
		}
		
		long getVal() {
			return minVal + lazy;
		}
		
		void inc(int lf, int rg, int v) {
			if(rg < L || R < lf) return;
			if(lf <= L && R <= rg) {
				lazy += v;
				return;
			}
			propagate();
			
			left.inc(lf, rg, v);
			right.inc(lf, rg, v);
			min();
		}
		
		long rmq(int lf, int rg) {
			if(rg < L || R < lf) return oo;
			if(lf <= L && R <= rg) {
				return getVal();
			}
			propagate();
			long res = Math.min(left.rmq(lf, rg), right.rmq(lf, rg)); 
			min();
			return res;
		}
		
		void min() {
			minVal = Math.min(left.getVal(), right.getVal());
		}
		
		void propagate() {
			left.lazy += lazy;
			right.lazy += lazy;
			lazy = 0;
		}
		
	}
}
