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

def add(node, value):
    tree[node] += value
    lazy[node] += value

def update(node, nodeRange, updateRange, value):
    if nodeRange[0] >= updateRange[0] and nodeRange[1] <= updateRange[1]:
        add(node, value)

    elif not (nodeRange[0] > updateRange[1] or nodeRange[1] < updateRange[0]):
        mid = sum(nodeRange) // 2

        if lazy[node] > 0:
            add(2*node, lazy[node])
            add(2*node, lazy[node])
            lazy[node] = 0

        update(2*node, (nodeRange[0], mid), updateRange, value)
        update(2*node + 1, (mid + 1, nodeRange[1]), updateRange, value)

        tree[node] = min(tree[2*node], tree[2*node + 1])

def query(node, nodeRange, queryRange):
    if nodeRange[0] >= queryRange[0] and nodeRange[1] <= queryRange[1]:
        return tree[node]

    elif nodeRange[0] > queryRange[1] or nodeRange[1] < queryRange[0]:
        return inf

    else:
        mid = sum(nodeRange) // 2

        if lazy[node] > 0:
            add(2*node, lazy[node])
            add(2*node + 1, lazy[node])
            lazy[node] = 0

        return min(
            query(2*node, (nodeRange[0], mid), queryRange),
            query(2*node + 1, (mid + 1, nodeRange[1]), queryRange)
        )

def getMinSegTree(array):
    def nextPowerOfTwo(num):
        return 1 << num.bit_length()

    length = 2*nextPowerOfTwo(n - 1)
    tree = [inf] * length

    for i in range(n):
        tree[length//2 + i] = array[i]

    for i in range(length - 1, 1, -1):
        tree[i//2] = min(tree[i//2], tree[i])

    return tree

n = int(input())
array = tuple(map(lambda x: int(x), input().split()))

tree = getMinSegTree(array)
lazy = [0] * len(tree)

rootRange = (0, n - 1)

m = int(input())
for i in range(m):
    inputData = tuple(map(lambda x: int(x), input().split()))

    if len(inputData) == 3: # update
        if inputData[0] > inputData[1]:
            update(1, rootRange, (inputData[0], n - 1), inputData[2])
            update(1, rootRange, (0, inputData[1]), inputData[2])

        else:
            update(1, rootRange, (inputData[0], inputData[1]), inputData[2])

    else: # query
        if inputData[0] > inputData[1]: # especial case
            print(min(
                query(1, rootRange, (inputData[0], n - 1)),
                query(1, rootRange, (0, inputData[1]))
            ))

        else: # normal
            print(query(1, rootRange, (inputData[0], inputData[1])))

  	 	 	        			 		 	 			   	