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.
from math import inf

def ri():
    return int(input())
 
def rl():
    return list(map(int, input().split()))

def init(i, a, b):
	lo[i] = a
	hi[i] = b

	if a == b:
		return

	m = (a+b)//2

	init(2*i, a,m)
	init(2*i+1, m+1,b)

def increment(a,b,val):
	return _increment(1,a,b,val)

def minimum(a,b):
	return _minimum(1,a,b)

def _increment(i, a, b, val):
	if (b < lo[i]) or (hi[i] < a):
		return

	if (a <= lo[i]) and (hi[i] <= b):
		segDelta[i] += val
		return

	prop(i)

	_increment(2*i, a, b, val)
	_increment(2*i + 1, a, b, val)

	update(i)

def _minimum(i, a,b):
	if (b < lo[i]) or (hi[i] < a):
		return inf

	if (a <= lo[i]) and (hi[i] <= b):
		return segMin[i] + segDelta[i]

	prop(i)

	minLeft = _minimum(2*i, a, b)
	minRight = _minimum(2*i+1,a,b)

	update(i)

	return min(minLeft, minRight)


def prop(i):
	segDelta[2*i] += segDelta[i]
	segDelta[2*i + 1] += segDelta[i]
	segDelta[i] = 0

def update(i):
	segMin[i] = min(segMin[2*i]+ segDelta[2*i], segMin[2*i+ 1] + segDelta[2*i + 1])


n = ri()
aa = rl()

segMin = [0]*(4*n + 1) 
segDelta = [0]*(4*n + 1)
lo = [-inf]*(4*n + 1)
hi = [inf]*(4*n + 1)
init(1,0,n-1)



for i in range(n):
	increment(i,i,aa[i])



m = ri()

for q in range(m):
	line = rl()
	if len(line) == 3:
		l, r, val = line

		if l > r:
			increment(l, n-1, val)
			increment(0, r, val)
		else:
			increment(l, r)
	else:
		l, r = line

		if l > r:
			mini = min(minimum(l, n-1), minimum(0,r))
		else:
			mini = minimum(l, r)
		print(mini)
















