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>
typedef long long ll;
const int INF=0x7f7f7f7f7f7f7f7f;
using namespace std;
const int N=200000+5;
int n,m;
bool space;
ll a[N],tree[N<<2],tag[N<<2];

inline ll read_long(){
	space=0;
	register ll s=0,w=1;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')w=-1;c=getchar();
	}
	while(c>='0'&&c<='9'){
		s=(s<<1)+(s<<3)+c-48,c=getchar();	
	}
	if(c==' '){
		space=1;
	}  
	return s*w;
}
inline int read_int(){
	space=0;
	register int s=0,w=1;
	register char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')w=-1;c=getchar();}
	while(c>='0'&&c<='9')s=(s<<1)+(s<<3)+c-48,c=getchar();
	if(c==' ')  space=1;
	return s*w;
}
inline ll min(const ll &a,const ll &b){
	return(a<b?a:b);
}

inline void build(const int &rt,const int &l,const int &r){
	if(l==r){
		tree[rt]=a[l];return;
	}
	const int mid=(l+r)>>1;
	build(rt<<1,l,mid);
	build(rt<<1|1,mid+1,r);
	tree[rt]=min(tree[rt<<1],tree[rt<<1|1]);
}
inline void update(const int &nl,const int &nr,const int &rt,const int &l,const int &r,const ll &v){
	if(nl<=l&&r<=nr){
		tag[rt]+=v;
		return;
	}
	const int mid=(l+r)>>1;
	if(nl<=mid){
		update(nl,nr,rt<<1,l,mid,v);
	}  
	if(mid<nr){
		update(nl,nr,rt<<1|1,mid+1,r,v);
	}  
	tree[rt]=min(tree[rt<<1]+tag[rt<<1],tree[rt<<1|1]+tag[rt<<1|1]);
}

inline ll query(const int &nl,const int &nr,const int &rt,const int &l,const int &r){
	if(nl<=l&&r<=nr){
		return tree[rt]+tag[rt];
	}  
	const int mid=(l+r)>>1;
	register ll left=INF,right=INF;
	if(nl<=mid){
		left=query(nl,nr,rt<<1,l,mid);
	}  
	if(mid<nr){
		right=query(nl,nr,rt<<1|1,mid+1,r);
	}  
	return min(left,right)+tag[rt];
}

int main(){
	n=read_int();
	for(register int i=1;i<=n;i++){
		a[i]=read_long();
	}  
	build(1,1,n);
	m=read_int();
	register int l,r;
	register ll v;
	while(m--){
		l=read_int();  r=read_int();
		l++;  r++;
		if(space){
			v=read_long();
			if(l>r){
				update(l,n,1,1,n,v),update(1,r,1,1,n,v);
			}else{
				update(l,r,1,1,n,v);
			}  
		}else{
			if(l>r){
				printf("%lld\n",min(query(l,n,1,1,n),query(1,r,1,1,n)));
			}else{
				printf("%lld\n",query(l,r,1,1,n));
			}  
		}
	}
	return 0;
}
		 		  		 		   			 	  			  		 	