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<bits/stdc++.h>
using namespace std;
#define int long long int
#define slld(x) scanf("%lld ",&(x))
#define sd(x) scanf("%lld ",&(x))
#define fi first
#define se second
#define mx 100001
#define md 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define pd(x) printf("%lld ",(x))
#define plld(x) printf("%lld ",(x))
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define br printf("\n")

int lazy[1000001] = {0};
int tree[1000001];
void build(int node,int start,int end,int a[])
{
	if(start==end)
	{
		tree[node] = a[start];
		return;
	}
	int mid = (start+end)/2;
	build(2*node,start,mid,a);
	build(2*node+1,mid+1,end,a);
	tree[node] = min(tree[2*node],tree[2*node+1]);
}
void update(int node,int start,int end,int l,int r,int x)
{
	if(lazy[node]!=0)
	{
		tree[node]+=lazy[node];
		if(start<end)
		{
			lazy[2*node]+=lazy[node];
			lazy[2*node+1]+=lazy[node];
		}
		lazy[node] = 0;
	}
	if(start>end||start>r||end<l)
		return;
	else if(l<=start&&end<=r)
	{
		tree[node]+=x;
		if(start<end)
		{
			lazy[2*node]+=x;
			lazy[2*node+1]+=x;
		}
		return;
	}
	int mid = (start+end)/2;
	update(2*node,start,mid,l,r,x);
	update(2*node+1,mid+1,end,l,r,x);
	tree[node] = min(tree[2*node],tree[2*node+1]);
}
int query(int node,int start,int end,int l,int r)
{
	if(start>end||start>r||end<l)
		return 1000000000000;
	if(lazy[node]!=0)
	{
		tree[node]+=lazy[node];
		if(start<end)
		{
			lazy[2*node]+=lazy[node];
			lazy[2*node+1]+=lazy[node];
		}
		lazy[node] = 0;
	}
	if(l<=start&&end<=r)
		return tree[node];
	int mid = (start+end)/2;
	return min(query(2*node,start,mid,l,r),query(2*node+1,mid+1,end,l,r));
}
main()
{
	//freopen("inputf.txt","r",stdin);
	int n;
	sd(n);
	int a[n+1];
	fr(i,1,n+1)
	sd(a[i]);
	build(1,1,n,a);
	int q;
	sd(q);
	while(q--)
	{
		string line;
		getline(cin,line);
		istringstream is(line);
		vector<int> vv = vector<int>(istream_iterator<int>(is),istream_iterator<int>() );
		if(vv.size()==3)
		{
			int l = vv[0]+1;
			int r = vv[1]+1;
			int x = vv[2];
			if(l>r)
			{
				update(1,1,n,l,n,x);
				update(1,1,n,1,r,x);
			}
			else
			{
				update(1,1,n,l,r,x);
			}
		}
		if(vv.size()==2)
		{
			int l = vv[0]+1;
			int r = vv[1]+1;
			if(l>r)
			{
				pd(min(query(1,1,n,l,n),query(1,1,n,1,r)));
			}
			else
			{
				pd(query(1,1,n,l,r));
			}
			br;
		}
	}
	return 0;
}