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.
'''input
4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1
'''
from sys import stdin, setrecursionlimit
import math
from bisect import bisect_left


def build_segment_tree(tree, index, arr, start, end):
    if start > end:
        return
    if start == end:
        tree[index] = arr[start]
        return

    else:
        mid = (start + end) // 2
        build_segment_tree(tree, 2 * index, arr, start, mid)
        build_segment_tree(tree, 2 * index + 1, arr, mid + 1, end)
        tree[index] = min(tree[2 * index + 1], tree[2 * index + 2])


def update(seg_tree, lazy_tree, index, start, end, v, qs, qe):
    # updating from lazy tree
    seg_tree[index] += lazy_tree[index]
    if start != end:
        lazy_tree[2 * index] += lazy_tree[index]
        lazy_tree[2 * index + 1] += lazy_tree[index]
    lazy_tree[index] = 0

    # no overlap
    if qe < start or qs > end:
        return

    # total overlap
    if qs <= start and qe >= end:
        seg_tree[index] += v
        if start != end:
            lazy_tree[2 * index] += v
            lazy_tree[2 * index + 1] += v
        return

    # partial overlap
    mid = (start + end) // 2
    update(seg_tree, lazy_tree, 2 * index, start, mid, v, qs, qe)
    update(seg_tree, lazy_tree, 2 * index + 1, mid + 1, end, v, qs, qe)
    seg_tree[index] = min(seg_tree[2 * index], seg_tree[2 * index + 1])
    return


def query(seg_tree, lazy_tree, index, start, end, qs, qe):
    # updating from lazy tree
    seg_tree[index] += lazy_tree[index]
    if start != end:
        lazy_tree[2 * index] += lazy_tree[index]
        lazy_tree[2 * index + 1] += lazy_tree[index]
    lazy_tree[index] = 0

    # no overlap
    if qe < start or qs > end:
        return float('inf')

    # total overlap
    if qs <= start and qe >= end:
        return seg_tree[index]

    # partial overlap
    mid = (start + end) // 2
    left = query(seg_tree, lazy_tree, 2 * index, start, mid, qs, qe)
    right = query(seg_tree, lazy_tree, 2 * index + 1, mid + 1, end, qs, qe)
    return min(left, right)


# main starts
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
m = int(stdin.readline().strip())
tree = [0] * (4 * n + 1)
lazy_tree = [0] * ( 4 * n + 1)
index = 1
start = 0
end = n - 1
build_segment_tree(tree, index, arr, start, end)
for _ in range(m):
	q = list(map(int, stdin.readline().split()))
	if len(q) == 3:
		l, r, v = q
		if l <= r:
			update(tree, lazy_tree, index, start, end, v, l, r)
		else:
			update(tree, lazy_tree, index, start, end, v,  l, n - 1)
			update(tree, lazy_tree, index, start, end, v, 0, r)
	else:
		l, r = q
		if l <= r:
			print(query(tree, lazy_tree, index, start, end, l, r))
		else:
			print(min(query(tree, lazy_tree, index, start, end, l, n - 1), query(tree, lazy_tree, index, start, end, 0, r)))
