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 collections import defaultdict as d
class st:
	def __init__(self, size):
		N = 1
		h = 0
		while N < size:
			N <<= 1
			h += 1
		self.N = N
		self.h = h
		self.t = [float('inf')] * (2 * N)
		self.d = [0] * N
    
	def apply(self, p, value):
		self.t[p] += value
		if (p < self.N):
			self.d[p] += value
    
	def build(self, p):
		t = self.t
		d = self.d
		while p > 1:
			p >>= 1
			t[p] = min(t[p<<1], t[p<<1|1]) + d[p]
    
	def rebuild(self):
		t = self.t
		for p in reversed(range(1, self.N)):
			t[p] = min(t[p<<1], t[p<<1|1])
    
	def push(self, p):
		d = self.d
		for s in range(self.h, 0, -1):
			i = p >> s
			if d[i] != 0:
				self.apply(i<<1, d[i])
				self.apply(i<<1|1, d[i])
				d[i] = 0
    
	def inc(self, l, r, value):
		if l >= r:
			return
 
		l += self.N
		r += self.N
		l0, r0 = l, r
		while l < r:
			if l & 1:
				self.apply(l, value)
				l += 1
			if r & 1:
				r -= 1
				self.apply(r, value)
			l >>= 1
			r >>= 1
		self.build(l0)
		self.build(r0 - 1)
    
	def query(self, l, r):
		if l >= r:
			return float('inf')
 
		t = self.t
		l += self.N
		r += self.N
		self.push(l)
		self.push(r - 1)
		res = float('inf')
		while l < r:
			if l & 1:
				res = min(res, t[l])
				l += 1
			if r & 1:
				r -= 1
				res = min(t[r], res)
			l >>= 1
			r >>= 1
		return res    

n = int(input())
ll = list(map(int, input().split()))
segment=st(n)
N=segment.N
for i in range(n):
	segment.t[i+N]=ll[i]
segment.rebuild()
m = int(input())
while m != 0:
  ques = list(map(int, input().split()))
  if len(ques) == 2:
    if ques[0] > ques[1]:
      print(min(segment.query(ques[0], n), segment.query(0, ques[1]+1)))
    else:
      print(segment.query(ques[0], ques[1]+1))
  else:
    if ques[0] > ques[1]:
      segment.inc(0, ques[1]+1, ques[-1])
      segment.inc(ques[0], n, ques[-1])
    else:
      segment.inc(ques[0], ques[1]+1, ques[-1])
  m -= 1
