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.
import sys


file_in, file_out = "input.txt", "output.txt"
sys.stdin = open(file_in, "r")
sys.setrecursionlimit(10**3)
# sys.stdout = open(file_out, "w")

INF = int(2e9)
sz = (1 << 19)

t = [INF] * (2 * sz - 1)
push = [0] * (2 * sz - 1)

def build(v, l, r, a):
	if l == r:
		if l < len(a):
			t[v] = a[l]
		return
	m = (l + r) // 2
	build(v * 2 + 1, l, m, a)
	build(v * 2 + 2, m + 1, r, a)
	t[v] = min(t[v * 2 + 1], t[v * 2 + 2])

def init(a):
	build(0, 0, sz - 1, a)

def makePush(v):
	t[v * 2 + 1] += push[v]
	t[v * 2 + 2] += push[v]
	push[v * 2 + 1] += push[v]
	push[v * 2 + 2] += push[v]
	push[v] = 0

def f_get_min(v, l, r, ql, qr):
	if ql <= l and r <= qr:
		return t[v]
	elif ql > r or l > qr:
		return INF
	makePush(v)
	m = (l + r) // 2
	return min(f_get_min(v * 2 + 1, l, m, ql, qr), f_get_min(v * 2 + 2, m + 1, r, ql, qr))

def get_min(l, r):
	return f_get_min(0, 0, sz - 1, l, r)

def f_inc(v, l, r, ql, qr, x):
	if ql <= l and r <= qr:
		t[v] += x
		push[v] += x
		return
	elif ql > r or l > qr:
		return
	makePush(v)
	m = (l + r) // 2
	f_inc(v * 2 + 1, l, m, ql, qr, x)
	f_inc(v * 2 + 2, m + 1, r, ql, qr, x)
	t[v] = min(t[v * 2 + 1], t[v * 2 + 2])

def inc(l, r, x):
	f_inc(0, 0, sz - 1, l, r, x)

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	init(a)

	m = int(input())
	for _ in range(m):
		query = list(map(int, input().split()))
		if len(query) > 2:
			l, r, x = query
			if l > r:
				inc(l, n - 1, x)
				inc(0, r, x)
			else:
				inc(l, r, x)
		else:
			l, r = query
			if l > r:
				print(min(get_min(l, n - 1), get_min(0, r)))
			else:
				print(get_min(l, r))


solve()