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

const int N = 200005;
long long a[N], f[N*4], lazy[N*4];

void build(int root, int left, int right)
{
	if(left == right)
	{
		f[root] = a[left];
		return ;
	}
	
	int mid = (left + right) >> 1;
	int 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 = root << 1;
	
	lazy[rt] += lazy[root];
	lazy[rt + 1] += lazy[root]; 
	
	f[rt] += lazy[root];
	f[rt + 1] += lazy[root];
	
	lazy[root] = 0;
}

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

	int mid = (left + right)>>1;
	int rt = root << 1;
	
	if(mid >= uleft)
	{
		update(rt, left, mid, uleft, uright, v);
	}
	if(mid < uright)
	{
		update(rt + 1, mid + 1, right, uleft, uright, v);
	}
	
	f[root] = min(f[rt], f[rt + 1]);
//	if(f[root] == -1)
//	{
//		printf(" aaa left:%d right£º%d\n", left, right);
//	}
}

long long qmin(int root, int left, int right, int uleft, int uright)
{
	if(left >= uleft && right <= uright)
	{
		return f[root];
	}
	
	if(lazy[root] != 0)
	{
		pushdown(root);
	}
//	if(f[root] == -1)
//	{
//		printf(" bbb left:%d right£º%d\n", left, right);
//	}
	int mid = (left + right) >> 1;
	int rt = root << 1;
	long long ans;
	ans = 0x3f3f3f3f;
	
	if(mid >= uleft)
	{
		ans = min(ans, qmin(rt, left, mid, uleft, uright));
	}
	if(mid < uright)
	{
		ans = min(ans, qmin(rt + 1, mid + 1, right, uleft, uright));
	}
	
	f[root] = min(f[rt], f[rt + 1]);
	
	return ans;
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1;i<=n;i++)
	{
		scanf("%I64d", &a[i]);
	}
	int m;
	scanf("%d", &m);
	getchar();
	build(1,1,n);
	memset(lazy, 0, sizeof(lazy));
	while(m--)
	{
		int x, y, z;
		int num;
		num = 0;
		char ch;
		int fllag = 1;
		scanf("%d", &x);
		while((ch = getchar())!='\n')
		{
			if(num++ == 0)
			{
				scanf("%d", &y);
			}
				
			else
			{
				scanf("%d", &z);
			}
		}
		x++;
		y++;
		if(num == 1)
		{
//			printf("%d %d\n", x, y);
			if(x > y)
			{
				printf("%I64d\n", min(qmin(1,1,n,x,n), qmin(1,1,n,1,y)));
			}
			else
			{
				printf("%I64d\n", qmin(1,1,n,x, y));
			}
		}
		else if(num == 2)
		{
//			printf("%d %d %d\n", x, y, z);
			if(x > y)
			{
//				printf("%I64d", min(qmin(1,1,n,y,n), qmin(1,1,n,1,x)));
				update(1,1,n, x, n, z);
				update(1,1,n, 1, y, z); 
			}
			else
			{
//				printf("%I64d", qmin(1,1,n,x, y));
				update(1,1,n,x,y,z);
			}
		}
	}
}
 	      	 								 		  		   	