You are given circular array *a*<sub class="lower-index">0</sub>, *a*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*n* - 1</sub>. 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.
The first line contains integer *n* (1 ≤ *n* ≤ 200000). The next line contains initial state of the array: *a*<sub class="lower-index">0</sub>, *a*<sub class="lower-index">1</sub>, ..., *a*<sub class="lower-index">*n* - 1</sub> ( - 10<sup class="upper-index">6</sup> ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>), *a*<sub class="lower-index">*i*</sub> 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; - 10<sup class="upper-index">6</sup> ≤ *v* ≤ 10<sup class="upper-index">6</sup>) — *inc* operation.
import java.io.*;
import java.util.*;
import java.lang.*;

public class Segment{
	public static void main(String args[]) throws Exception{

		Scanner sc= new Scanner(System.in);

		int n=sc.nextInt();

		SegmentTree st=new SegmentTree(1,n);




		
		for(int i=1;i<=n;i++) st.add(i,i,sc.nextInt());
		int t=sc.nextInt();
		sc.nextLine();
		while(t-->0){
			String [] line = sc.nextLine().split(" ");
			int l = Integer.parseInt(line[0])+1;
			int r = Integer.parseInt(line[1])+1;

			if (line.length == 2)
			{
				long res = Long.MAX_VALUE;
				if (l > r)
				{	res = Math.min(res,st.min(l,n));
					res = Math.min(res,st.min(1,r));
				} 
				else 
					res = Math.min(res,st.min(l, r));
				System.out.println(res);
			}
			else
			{
				int  val = Integer.parseInt(line[2]);
				if (l > r)
				{
					st.add(1, r, val);
					st.add(l, n, val);
				}
				else
					st.add(l, r, val);
			}
		}

	}
}

class SegmentTree {
		SegmentTree l=null,r=null;
		int lo,hi;
		long delta,min;
		
		SegmentTree(int lo, int hi) {
			this.lo=lo;
			this.hi=hi;
			delta=0L;
			min=0L;
			if(lo!=hi) {
				int m=(lo+hi)/2;
				l=new SegmentTree(lo,m);
				r=new SegmentTree(m+1,hi);
			}
		}
		
		void add(int nlo, int nhi, int add) {
			if(nlo<=lo&&hi<=nhi) {
				//covers entire interval
				delta+=add;
				return;
			}
			if(lo>nhi||hi<nlo) {
				//covers nothing
				return;
			}
			push();
			l.add(nlo,nhi,add);
			r.add(nlo,nhi,add);
			update();		
		}
		
		long min(int nlo, int nhi) {
			if(nlo<=lo&&hi<=nhi) {
				//covers entire interval
				return min+delta;
			}
			if(lo>nhi||hi<nlo) {
				//covers nothing
				return Long.MAX_VALUE;
			}
			push();
			long left=l.min(nlo,nhi);
			long right=r.min(nlo,nhi);
			update();
			
			return Math.min(left,right);
		}
		void update() {
			min=Math.min(l.min+l.delta,r.min+r.delta);
		}
		void push() {
			l.delta+=delta;
			r.delta+=delta;
			delta=0;
		}
}



