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 ceil, log2
INF = 10**18

class Node:
    def __init__(self, mina = 0, lazy = 0):
        self.mina = mina
        self.lazy = lazy


def buildTree(a, segtree, left, right, index):
    if left == right:
        segtree[index].mina = a[left]
        return
    mid = (left + right) // 2
    buildTree(a, segtree, left, mid, 2 * index + 1)
    buildTree(a, segtree, mid + 1, right, 2 * index + 2)


def updateQuery_minRangeLazy(segtree, left, right, fr, to, delta, index):
    if left > right:
        return

    # make sure all propagation is done at index. If not update tree
    # at index and mark its children for lazy propagation.
    if segtree[index].lazy != 0:
        segtree[index].mina += segtree[index].lazy
        if left != right:
            segtree[2 * index + 1].lazy += segtree[index].lazy
            segtree[2 * index + 2].lazy += segtree[index].lazy
        segtree[index].lazy = 0

    # no overlap condition
    if fr > right or to < left:
        return

    # total overlap condition
    if fr <= left and right <= to:
        segtree[index].mina += delta
        if left != right:
            segtree[2 * index + 1].lazy += delta
            segtree[2 * index + 2].lazy += delta
        return

    # otherwise partial overlap so look both left and right
    mid = (left + right) // 2
    updateQuery_minRangeLazy(segtree, left, mid, fr, to, delta, 2 * index + 1)
    updateQuery_minRangeLazy(segtree, mid + 1, right, fr, to, delta, 2 * index + 2)
    segtree[index].mina = min(segtree[2 * index + 1].mina, segtree[2 * index + 2].mina)


def minRangeLazy(segtree, left, right, fr, to, index):
    if left > right:
        return INF

    # make sure all propagation is done at index. If not update tree
    # at index and mark its children for lazy propagation.
    if segtree[index].lazy != 0:
        segtree[index].mina += segtree[index].lazy
        if left != right: # not a leaf node
            segtree[2 * index + 1].lazy += segtree[index].lazy
            segtree[2 * index + 2].lazy += segtree[index].lazy
        segtree[index].lazy = 0

    # no overlap
    if fr > right or to < left:
        return INF

    # total overlap
    if fr <= left and to >= right:
        return segtree[index].mina

    # partial overlap
    mid = (left + right) // 2
    return min(minRangeLazy(segtree, mid + 1, right, fr, to, 2 * index + 2),
               minRangeLazy(segtree, left, mid, fr, to, 2 * index + 1))


def circularUpdate(n, segtree, fr, to, delta):
    if fr <= to:
        updateQuery_minRangeLazy(segtree, 0, n - 1, fr, to, delta, 0)
        return
    updateQuery_minRangeLazy(segtree, 0, n - 1, fr, n - 1, delta, 0)
    updateQuery_minRangeLazy(segtree, 0, n - 1, 0, to, delta, 0)


def circularQuery(n, segtree, fr, to):
    if fr <= to:
        return minRangeLazy(segtree, 0, n - 1, fr, to, 0)
    return min(minRangeLazy(segtree, 0, n - 1, fr, n - 1, 0), minRangeLazy(segtree, 0, n - 1, 0, to, 0))

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

    h = ceil(log2(n))
    sizeTree = 2 * (2 ** h) - 1

    segtree = [Node() for i in range(sizeTree)]
    buildTree(a, segtree, 0, n - 1, 0)
    q = int(input())
    for i in range(q):
        line = list(map(int, input().split()))
        if len(line) == 3:
            circularUpdate(n, segtree, line[0], line[1], line[2])
        else:
            print(circularQuery(n, segtree, line[0], line[1]))
