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.
class segment_tree:
    tree_add = []
    tree_min = []
    size = 1
    def init(n):
        while(segment_tree.size < n):
            segment_tree.size *= 2
        segment_tree.tree_add = [0] * (2 * segment_tree.size - 1)
        segment_tree.tree_min = [0] * (2 * segment_tree.size - 1)
    def addFunc(l, r, lx, rx, cur, v):
        if(lx >= r or rx <= l):
            return
        if(lx >= l and rx <= r):
            segment_tree.tree_add[cur] += v
            segment_tree.tree_min[cur] += v
            return
        mid = (rx + lx) // 2
        segment_tree.addFunc(l, r, mid, rx, 2 * cur + 2, v)
        segment_tree.addFunc(l, r, lx, mid, 2 * cur + 1, v)
        segment_tree.tree_min[cur] = min(segment_tree.tree_min[2 * cur + 1], segment_tree.tree_min[2 * cur + 2]) + segment_tree.tree_add[cur]
    def add(l, r, v):
       segment_tree.addFunc(l, r, 0, segment_tree.size, 0, v)
    def minFunc(l, r, lx, rx, cur):
        if(lx >= r or rx <= l):
            return 1e18;
        if(lx >= l and rx <= r):
            return segment_tree.tree_min[cur]
        mid = (rx + lx) // 2;
        m1 = segment_tree.minFunc(l, r, mid, rx, 2 * cur + 2)
        m2 = segment_tree.minFunc(l, r, lx, mid, 2 * cur + 1)
        res = min(m1, m2)
        return res + segment_tree.tree_add[cur]
    def Min(l, r):
        return segment_tree.minFunc(l, r, 0, segment_tree.size, 0)
n = int(input())
a = list(map(int, input().split()))
segment_tree.init(n)
for i in range(len(a)):
    segment_tree.add(i, i + 1, a[i])
q = int(input())
for __ in range(q):
    x = list(map(int, input().split()))
    if len(x) == 2:
        l = x[0] 
        r = x[1]
        if(l <= r):
            print(segment_tree.Min(l, r + 1))
        else:
            print(min(segment_tree.Min(l, n), segment_tree.Min(0, r + 1)))
    else:
        l = x[0] 
        r = x[1]
        v = x[2]
        if(l <= r):
            segment_tree.add(l, r + 1, v)
        else:
            segment_tree.add(l, n, v)
            segment_tree.add(0, r + 1, v)