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.
MAX = 200000

seg = [0 for i in range(0,MAX*4)]
lazy = [0 for i in range(0,MAX*4)]

def propaga(ind, left, right):
	global ele,seg,lazy
	if(lazy[ind] != 0):
		seg[ind] += ((right - left)+1)*lazy[ind]
		if(left != right):
			lazy[ind*2] += lazy[ind]
			lazy[ind*2+1] += lazy[ind]
		lazy[ind] = 0


def build(ind, left, right):
	global ele,seg,lazy
	if left == right:
		seg[ind] = ele[left-1];	
	else:
		m = (left+right)//2
		build(ind*2,left,m)
		build(ind*2+1,m+1,right)
		seg[ind] = min(seg[ind*2],seg[ind*2+1])


def update(ind, left, right, x, y, v):
	global ele,seg,lazy
	if(left > y or right < x):
		propaga(ind,left,right)
	elif(left >= x and right <= y):
		lazy[ind] += v
		propaga(ind,left,right)
	else:
		propaga(ind,left,right)
		m = (left+right)//2
		update(ind*2,left,m,x,y,v)
		update(ind*2+1,m+1,right,x,y,v)
		seg[ind] = min(seg[ind*2],seg[ind*2+1])


def query(ind, left, right, x, y):
	propaga(ind,left,right)
	if(left > y or right < x):
		return 1000000000
	elif(left >= x and right <= y):
		return seg[ind]
	else:
		m = (left+right)//2
		return min(query(ind*2,left,m,x,y),query(ind*2+1,m+1,right,x,y))
	
n = int(input())

ele = list(map(int,input().split()))

build(1,1,n)

q = int(input())

for i in range(q):
	l = list(map(int,input().split()))
	if(len(l) == 2):
		a = l[0] + 1
		b = l[1] + 1
		if a > b:
			print("%d"%(min(query(1,1,n,a,n),query(1,1,n,1,b))))
		else:
			print("%d"%(query(1,1,n,a,b)))
	else:
		a = l[0]+1
		b = l[1]+1
		c = l[2]
		if a > b:
			update(1,1,n,a,n,c)
			update(1,1,n,1,b,c)
		else:
			update(1,1,n,a,b,c)
	    	 			  	 	   		    		