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 Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		long[] nums = new long[N];
		for (int i = 0; i < N; i++)
			nums[i] = sc.nl();
		SegmentTree st = new SegmentTree(nums);
		int Q = sc.ni();
		for (int q = 0; q < Q; q++) {
			String[] query = sc.nextLine().split(" ");
			int L = Integer.parseInt(query[0])+1;
			int R = Integer.parseInt(query[1])+1;
			if (query.length == 2) {
				//RMQ(L,R)
				if (L > R) {
					//Circular RMQ
					pw.println(Math.min(st.minQuery(1, 1, N, L, N),st.minQuery(1, 1, N, 1, R)));
				} else {
					//Regular RMQ
					pw.println(st.minQuery(1, 1, N, L, R));
				}
			} else {
				long val = Long.parseLong(query[2]);
				if (L > R) {
					//Circular update
					st.add(1, 1, N, L, N, val);
					st.add(1, 1, N, 1, R, val);
				} else {
					//Regular RMQ
					st.add(1, 1, N, L, R, val);
				}
			}
		}
		pw.close();
 	}
	
	static class SegmentTree {
		public Node[] ranges;

		public SegmentTree(long[] array) {
			ranges = new Node[4*array.length+1];
			for (int i = 0; i < ranges.length; i++) {
				ranges[i] = new Node();
			}
			for (int i = 0; i < array.length; i++) {
				add(1,1,array.length,i+1,i+1,array[i]);
			}
		}

		//range update nums[updateL..updateR] += val;
		public void add(int n, int L, int R, int updateL, int updateR, long val) {
			push(n,L,R);
			if (updateL <= L && R <= updateR) {
				//fully contained
				ranges[n].lazy += val;
				push(n,L,R);
				return;
			} else if (L>updateR || R<updateL || L==R) {
				//not contained at all or leaf
				return;
			}
			add(2*n,L,(L+R)/2,updateL,updateR,val); 
			add(2*n+1,(L+R)/2+1,R,updateL,updateR,val);
			ranges[n].min = Math.min(ranges[2*n].min,ranges[2*n+1].min);
		}

		public long minQuery(int n, int L, int R, int Lq, int Rq) {
			push(n,L,R);
			if (Lq <= L && R <= Rq) {
				return ranges[n].min;
			} else if (R < Lq || Rq < L || L==R) {
				return 1000000000000007L;
			} else {
				return Math.min(minQuery(2*n,L,(L+R)/2,Lq,Rq),minQuery(2*n+1,(L+R)/2+1,R,Lq,Rq));
			}
		}

		public void push(int n, int L, int R) {
			ranges[n].min += ranges[n].lazy;

			if (L < R) {
				ranges[2*n].lazy += ranges[n].lazy;
				ranges[2*n+1].lazy += ranges[n].lazy;
			}

			ranges[n].lazy = 0;
		}

		static class Node {
			public long min;
			public long lazy;

			public Node() {
			}
		}
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
  
        int ni() { 
            return Integer.parseInt(next()); 
        } 
  
        long nl() { 
            return Long.parseLong(next()); 
        }
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}