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

import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



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, val)
	else:
		l, r = line

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
















