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<cstring>
#include<algorithm>
#include<cmath> 
using namespace std;
typedef long long ll;

const int N=200005;
ll f[N<<2],lazy[N<<2];

void build(int root,int left,int right){
	lazy[root]=0;
	if(left==right){
		scanf("%lld",&f[root]);
		return;
	}
	int mid,rt;
	mid=(left+right)>>1;
	rt=root<<1;
	build(rt,left,mid);
	build(rt+1,mid+1,right);
	f[root]=min(f[rt],f[rt+1]);
}

void pushdown(int root){
	int rt;
	ll s;
	rt=root<<1;
	s=f[root];
	f[rt]+=s;
	f[rt+1]+=s;
	lazy[rt]+=s;
	lazy[rt+1]+=s;
	lazy[root]=0;
}

void update(int root,int left,int right,int uleft,int uright,int val){
    int mid,rt;
	mid=(left+right)>>1;
	rt=root<<1;
	if(uleft<=left&&right<=uright){
		f[root]+=val;
		lazy[root]+=val;
		return;
	}
	if(lazy[root]!=0){
		pushdown(root);
	}
	if(uright<=mid){
		update(rt,left,mid,uleft,uright,val);
	}else if(mid<uleft){
		update(rt+1,mid+1,right,uleft,uright,val);
	}else{
		update(rt,left,mid,uleft,uright,val);
		update(rt+1,mid+1,right,uleft,uright,val);
	}
	f[root]=min(f[rt],f[rt+1]);
}

ll query(int root,int left,int right,int qleft,int qright){
	int rt,mid;
	ll ans;
	rt=root<<1;
	mid=(left+right)>>1; 
	if(qleft<=left&&right<=qright){
		return f[root];
	}
	if(lazy[root]!=0){
		pushdown(root);
	}
	if(qright<=mid){
		ans=query(rt,left,mid,qleft,qright);
	}else if(qleft>mid){
		ans=query(rt+1,mid+1,right,qleft,qright);
	}else{
		ans=min(query(rt,left,mid,qleft,qright),query(rt+1,mid+1,right,qleft,qright));
	}
	return ans;
} 

int main(){
	int n,m;
	ll ans;
	scanf("%d",&n);
	build(1,1,n);
	int l,r,x;
	scanf("%d",&m);
	while(m>0){
		scanf("%d%d",&l,&r);
		l+=1;
		r+=1;
		if(getchar()=='\n'){
			if(left<=right){
				ans=query(1,1,n,l,r);
			}else{
				ans=min(query(1,1,n,l,n),query(1,1,n,1,r));
			}
			printf("%lld\n",ans);
		}else{
			scanf("%d",&x);
			if(l<=r){
				update(1,1,n,l,r,x);
			}else{
				update(1,1,n,l,n,x);
				update(1,1,n,1,r,x);
			}
		}
		m--;
	}
	return 0;
}











	   	 		 	 		 			 		  	 	 		 	