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 sys
inp = lambda: sys.stdin.readline().rstrip("\r\n")
fp = lambda p: sys.stdout.write(str(p) + "\n")

def LazySegmentTree(arr,n):
    tree = [inf] * (4 * n)
    lazy = [0] * (4 * n)
    build(tree,arr)
    return tree,lazy
def build(tree,arr):
    q = [(1, 1, 0, n -1)]
    while q:
        a, index, tl,tr = q.pop()
        if a == 1:
            if tl == tr:
                tree[index] = arr[tl]
            else:
                tm = (tl + tr) // 2
                q.append((2, index, tl, tr))
                q.append((1, index*2, tl, tm))
                q.append((1, index*2+1, tm+1, tr))
        else:
            tree[index] = min(tree[index*2], tree[index*2+1])

def propagar(tree,lazy, index):
    tree[2 * index] += lazy[index]
    lazy[2*index] += lazy[index]
    tree[2 * index + 1] += lazy[index]
    lazy[2*index +1] += lazy[index]

    lazy[index] = 0

def update_range(tree,lazy,left, right, val):
    q = [(1, 1, 0, len(tree) //4-1, left, right)]
    while q:
        a, index, tl, tr, left, right = q.pop()
        if a == 1:
            if left > right:
                continue
            if tl == left and tr == right:
                tree[index] += val
                lazy[index] += val
            else:
                propagar(tree,lazy,index)
                tm = (tl + tr) // 2
                q.append((2, index, tl, tr, left, right))
                q.append((1, index*2, tl, tm, left, min(right, tm)))
                q.append((1, index*2+1, tm+1, tr, max(left, tm+1), right))
        else:
            tree[index] = min(tree[index*2], tree[index*2+1])

def query_range(tree,lazy, left, right):
    q = [(1, 1, 0, len(tree) //4 - 1, left, right)]
    res = []
    while q:
        a, index, tl, tr, left, right = q.pop()
        if a == 1:
            if left > right:
                res.append(inf)
                continue
            if left == tl and tr == right:
                res.append(tree[index])
                continue
            propagar(tree,lazy,index)
            tm = (tl + tr) // 2
            q.append((2, index, tl, tr, left, right))
            q.append((1, index*2, tl, tm, left, min(tm, right)))
            q.append((1, index*2+1, tm+1, tr, max(left, tm+1), right))
        else:
            res.append(min(res.pop(), res.pop()))
    return res[0]

n = int(inp())
arr = list(map(int,sys.stdin.readline().split()))
#arr = list(map(int, input().split()))
tree,lazy = LazySegmentTree(arr,n)
q = int(inp())
for _ in range(q):
    query = list(map(int, sys.stdin.readline().split()))
    #query = list(map(int, input().split()))
    if len(query) == 2:
        if query[0] <= query[1]:
            fp(query_range(tree,lazy,query[0], query[1]))
        else:
            a = query_range(tree,lazy,0, query[1])
            b = query_range(tree,lazy,query[0], n-1)
            fp(min(a,b))
    else:
        if query[0] <= query[1]:
            update_range(tree,lazy,query[0], query[1], query[2])
        else:
            update_range(tree,lazy,0, query[1], query[2])
            update_range(tree,lazy,query[0], n-1, query[2])