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.
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e6+5,INF=0x7777777;
long long a[N],f[4*N],lazy[4*N];
void build(int root,int left,int right){
	lazy[root]=0;
	if(left==right){
		f[root]=a[left];
		return;
	}
	
	int rt,mid;
	rt=root<<1;
	mid=(left+right)>>1;
	
	build(rt,left,mid);
	build(rt+1,mid+1,right);
	 
	f[root]=min(f[rt],f[rt+1]);
}
void pushdown(int root,int left,int right){
	int rt,mid;
	rt=root<<1;
	mid=(left+right)>>1;
	
	int s=lazy[root];
	f[rt]+=s*(mid-left+1);
	f[rt+1]+=s*(right-mid);
	
	lazy[rt]+=s;
	lazy[rt+1]+=s;
	lazy[root]=0;
}
void update(int root,int left,int right,int uleft,int uright,long long val){
	if(uleft<=left&&right<=uright){
		f[root]+=val*(right-left+1);
		lazy[root]+=val;
		return;
	}
	if(lazy[root]){
		pushdown(root,left,right);
	}
	
	int rt,mid;
	rt=root<<1;
	mid=(left+right)>>1;
	
	if(uleft<=mid){
		update(rt,left,mid,uleft,uright,val);
	}
	if(mid<uright){
		update(rt+1,mid+1,right,uleft,uright,val);
	}
	
	f[root]=min(f[rt],f[rt+1]);
}
long long query(int root,int left,int right,int qleft,int qright){
	if(qleft<=left&&right<=qright){
		return f[root];
	}
	if(lazy[root]){
		pushdown(root,left,right);
	}
	
	int rt,mid;
	rt=root<<1;
	mid=(left+right)>>1;
	
	long long ans=INF;
	if(qleft<=mid){
		ans=min(ans,query(rt,left,mid,qleft,qright));
	}
	if(mid<qright){
		ans=min(ans,query(rt+1,mid+1,right,qleft,qright));
	}
	return ans;
}
int main(){
	int n,m,l,r;
	long long v;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	build(1,1,n);
	cin>>m;
	for(int i=0;i<m;i++){
		char ch;
		scanf("%d %d",&l,&r);
		l++;
		r++;
		if(getchar()!=' '){
			if(l<r){
				cout<<query(1,1,n,l,r)<<endl;
			}else{
				cout<<min(query(1,1,n,l,n),query(1,1,n,1,r))<<endl;
			}											
		}else{		
			cin>>v;
			if(l<r){
				update(1,1,n,l,r,v);
			}else{
				update(1,1,n,l,n,v);
				update(1,1,n,1,r,v);
			}		
		}
	}
	return 0;
}

  	 	 	    	   	 	   	  	   			