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<iostream>
using namespace std;
typedef long long ll;
const ll N=200100;
ll a[N];
ll minn[N<<2];
ll lazy[N<<2];

void build(ll root,ll left,ll right){
	lazy[root]=0;
	if(left==right){
		minn[root]=a[left];
		return ;
	}
	
	ll rt,mid;
	rt=root<<1;
	mid=left+right>>1;
	
	build(rt,left,mid);
	build(rt+1,mid+1,right);
	
	minn[root]=min(minn[rt],minn[rt+1]);
}



void update(ll root,ll left,ll right,ll qleft,ll qright,ll val){
//	cout<<"l:"<<left<<' '<<"r:"<<right<<' '<<"ql:"<<qleft<<' '<<"qr:"<<qright<<' '<<"v:"<<val<<' '<<"minn:"<<minn[root]<<endl;
	if(qleft>right||qright<left){
		return ;
	}
	
	if(qleft<=left&&right<=qright){
		minn[root]+=val;
		lazy[root]+=val;
		return ;
	}
	
	ll rt,mid;
	rt=root<<1;
	mid=left+right>>1;
	
	
	if(lazy[root]){
		lazy[rt]+=lazy[root];
		lazy[rt+1]+=lazy[root];
		minn[rt]+=lazy[root];
		minn[rt+1]+=lazy[root];
		lazy[root]=0;
	}
	
	if(qleft<=mid){
		update(rt,left,mid,qleft,qright,val);
	}
	if(qright>mid){
		update(rt+1,mid+1,right,qleft,qright,val);
	}
	
	minn[root]=min(minn[rt],minn[rt+1]);
	
}

ll query(ll root,ll left,ll right,ll qleft,ll qright){
	
//	cout<<"l:"<<left<<' '<<"r:"<<right<<' '<<"ql:"<<qleft<<' '<<"qr:"<<qright<<' '<<"minn:"<<minn[root]<<endl;
	
	
	if(qleft<=left&&right<=qright){
		return minn[root];
	}
	
	ll rt,mid;
	rt=root<<1;
	mid=left+right>>1;
	
	if(lazy[root]){
		lazy[rt]+=lazy[root];
		lazy[rt+1]+=lazy[root];
		minn[rt]+=lazy[root];
		minn[rt+1]+=lazy[root];
		lazy[root]=0;
	}
	ll ans=1000000000,t;
	if(qleft<=mid){
		t=query(rt,left,mid,qleft,qright);
		ans=min(ans,t);
	}
	if(qright>mid){
		t=query(rt+1,mid+1,right,qleft,qright);
		ans=min(ans,t);
	}
	
	return ans;
	
}

//int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);
//	
//	
//	ll n,m,l,r,v,t;
//	
//	cin>>n;
//	for(ll i=0;i<n;i++){
//		cin>>a[i];
//	}
//	
//	build(1,0,n-1);
//	
//	for(int i=1;i<=(n<<2);i++){
//		cout<<i<<':'<<minn[i]<<' ';
//	}
//	cout<<endl;
//	
//	
//	cin>>m;
//	
//	while(m--){
//		scanf("%d%d",&l,&r);
//		char c=getchar();
//		if(c=='\n'){
//			
//			cout<<"l:"<<l<<' '<<"r:"<<r<<endl;
//			
//			if(l<=r){
//				cout<<query(1,0,n-1,l,r)<<endl;
//			}else{
//				ll m=query(1,0,n-1,l,n-1);
//				ll n=query(1,0,n-1,0,r);
//				cout<<min(m,n)<<endl;
//			}
//		}else{
//			cin>>v;
//			if(l<=r){
//				update(1,0,n-1,l,r,v);
//			}else{
//				update(1,0,n-1,l,n-1,v);
//				update(1,0,n-1,0,r,v);
//			}
//		}
//		
//			for(int i=1;i<=(n<<2);i++){
//				cout<<i<<':'<<minn[i]<<' ';
//			}
//			cout<<endl;
//			
//	}
//	return 0;
//}

int main(){
	ll n,m,l,r,x,t;
	
    scanf("%d", &n);
    
	for(ll i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	build(1,0,n-1);
    
    scanf("%d", &m);
    while(m--)
    {
        scanf("%lld%lld", &l, &r);
        
        if(getchar() != '\n')
        {
            scanf("%lld", &x);
            if(l <= r) update(1, 0, n-1, l, r, x);
            else
            {
                update(1, 0, n-1, l, n-1, x);
                update(1, 0, n-1, 0, r, x);
            }
        }
        else
        {
            if(l <= r) printf("%lld\n", query(1, 0, n-1, l, r));
            else printf("%lld\n", min(query(1, 0, n-1, l, n-1), query(1, 0, n-1, 0, r)));
        }
    }
    return 0;
}

 		    	   		 		 		   				    	