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 gc
import heapq
import itertools
import math
from collections import Counter, deque, defaultdict
from sys import stdout
import time
from math import factorial, log, gcd
import sys
from decimal import Decimal
import threading
from heapq import *
from fractions import Fraction
import bisect


def S():
	return sys.stdin.readline().split()


def I():
	return [int(i) for i in sys.stdin.readline().split()]


def II():
	return int(sys.stdin.readline())


def IS():
	return sys.stdin.readline().replace('\n', '')


class SegTree:
	def __init__(self, a, n):
		self.a = a
		self.n = n
		self.size = 1
		while self.size < n:
			self.size *= 2
		
		self.tree = [[float('inf'), 0] for _ in range(2 * self.size - 1)]
		self._build(0, 0, self.size)
	
	def _build(self, x, lx, rx):
		if rx - lx == 1:
			if lx < self.n:
				self.tree[x][0] = self.a[lx]
			return
		
		m = (rx + lx) // 2
		self._build(2 * x + 1, lx, m)
		self._build(2 * x + 2, m, rx)
		self.tree[x][0] = min(self.tree[2 * x + 1][0], self.tree[2 * x + 2][0])
	
	def _set(self, left, right, v, x, lx, rx):
		if left <= lx and rx <= right:
			self.tree[x][1] += v
			self.tree[x][0] += v
			return
		if rx <= left or right <= lx:
			return
		m = (rx + lx) // 2
		self._set(left, right, v, 2 * x + 1, lx, m)
		self._set(left, right, v, 2 * x + 2, m, rx)
		self.tree[x][0] = min(self.tree[2 * x + 1][0], self.tree[2 * x + 2][0])
		
	def set(self, left, right, v):
		self._set(left, right, v, 0, 0, self.size)
		
	def _get(self, left, right, x, lx, rx, c):
		if left <= lx and rx <= right:
			return self.tree[x][0] + c
		if rx <= left or right <= lx:
			return float('inf')
		
		m = (rx + lx) // 2
		mn1 = self._get(left, right, 2 * x + 1, lx, m, c + self.tree[x][1])
		mn2 = self._get(left, right, 2 * x + 2, m, rx, c + self.tree[x][1])
		
		return min(mn1, mn2)
	
	def get(self, left, right):
		return self._get(left, right, 0, 0, self.size, 0)


def main():
	n = II()
	a = I()
	tree = SegTree(a, n)
	q = II()
	for _ in range(q):
		z = I()
		if len(z) == 2:
			left, right = z
			if left > right:
				print(min(tree.get(left, n), tree.get(0, right + 1)))
			else:
				print(tree.get(left, right + 1))
		else:
			left, right, v = z
			if left > right:
				tree.set(left, n, v)
				tree.set(0, right + 1, v)
			else:
				tree.set(left, right + 1, v)


if __name__ == '__main__':
	# for _ in range(II()):
	# 	main()
	main()
