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 numpy as np

class LazySegmentTree:
	"""Lazy min segment tree"""

	def __init__(self, n, dtype = np.int64):
		self.n = n
		self.tree = np.zeros(self.n * 4 + 1, dtype = dtype)
		self.delta = np.zeros(self.n * 4 + 1, dtype = dtype)

	def prop(self, node):
		"""Propage update down the tree"""
		#print("prop", node, self.tree[node], self.delta[node])
		if self.delta[node] != 0:
			self.tree[node] += self.delta[node]
			self.delta[2 * node] += self.delta[node]
			self.delta[2 * node + 1] += self.delta[node]
			self.delta[node] = 0

	def update(self, node):
		self.tree[node] = min((self.tree[2 * node] + self.delta[2 * node]), (self.tree[2 * node + 1] + self.delta[2 * node + 1]))

	def rangeIncrement(self, i, j, delta):
		self.recRangeIncrement(i, j, delta, 1, 0, self.n - 1)

	def rangeMin(self, i, j):
		return self.recRangeMin(i, j, 1, 0, self.n - 1)

	def recRangeIncrement(self, rangeLeft, rangeRight, delta, node, currentLeft, currentRight):
		if currentLeft > rangeRight or currentRight < rangeLeft:
			# Out of range
			return

		if currentLeft >= rangeLeft and currentRight <= rangeRight:
			# Within range
			self.delta[node] += delta
			return

		# Partial coverage
		self.prop(node)

		mid = (currentLeft + currentRight) // 2
		self.recRangeIncrement(rangeLeft, rangeRight, delta, 2 * node, currentLeft, mid)
		self.recRangeIncrement(rangeLeft, rangeRight, delta, 2 * node + 1, mid + 1, currentRight)

		self.update(node)

	def recRangeMin(self, rangeLeft, rangeRight, node, currentLeft, currentRight):
		if currentLeft > rangeRight or currentRight < rangeLeft:
			# Out of range
			return np.Inf

		#print("Current", currentLeft, currentRight)

		if currentLeft >= rangeLeft and currentRight <= rangeRight:
			# Within range
			return (self.tree[node] + self.delta[node])

		# Partial coverage
		self.prop(node)

		mid = (currentLeft + currentRight) // 2
		leftMin = self.recRangeMin(rangeLeft, rangeRight, 2 * node, currentLeft, mid)
		rightMin = self.recRangeMin(rangeLeft, rangeRight, 2 * node + 1, mid + 1, currentRight)

		self.update(node)
		
		return min(leftMin, rightMin)

	def populate(self, a):
		if self.n != len(a):
			print("ERROR: array length does not equal pre-set size; abort populate")
			return
		self.recPopulate(a, 1, 0, self.n - 1)

	def recPopulate(self, a, node, currentLeft, currentRight):
		if currentLeft == currentRight:
			self.tree[node] = a[currentLeft]
			self.delta[node] = 0
			return

		mid = (currentLeft + currentRight) // 2
		self.recPopulate(a, 2 * node, currentLeft, mid)
		self.recPopulate(a, 2 * node + 1, mid + 1, currentRight)

		self.tree[node] = min(self.tree[2 * node], self.tree[2 * node + 1])
		self.delta[node] = 0

if __name__ == "__main__":
	n = int(input())
	a = list(map(int, input().strip().split(" ")))

	seg_tree = LazySegmentTree(n)
	seg_tree.populate(a)

	q = int(input())
	while q > 0:
		q -= 1

		ops = list(map(int, input().strip().split(" ")))
		if len(ops) == 2:
			left, right = ops
			if left <= right:
				print(seg_tree.rangeMin(left, right))
			else:
				print(min(seg_tree.rangeMin(0, right), seg_tree.rangeMin(left, n - 1)))
		else:
			left, right, delta = ops
			if left <= right:
				seg_tree.rangeIncrement(left, right, delta)
			else:
				seg_tree.rangeIncrement(0, right, delta)
				seg_tree.rangeIncrement(left, n - 1, delta)