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.
tree = [[0, 0] for i in range(801000)]


def build(v, l, r):
    if l == r:
        tree[v][0] = a[l]
        return
    m = (l + r) // 2
    build(v * 2, l, m)
    build(v * 2 + 1, m + 1, r)
    tree[v][0] = min(tree[v * 2][0], tree[v * 2 + 1][0])


def update(v, l, r, ql, qr, x):
    if ql <= l and r <= qr:
        tree[v][0] += x
        tree[v][1] += x
        return
    if r < ql or qr < l:
        return
    m = (l + r) // 2
    update(2 * v, l, m, ql, qr, x)
    update(2 * v + 1, m + 1, r, ql, qr, x)
    tree[v][0] = min(tree[v * 2][0], tree[v * 2 + 1][0])


def get(v, l, r, ql, qr):
    # print(l, r)
    if ql <= l and r <= qr:
        # print("$", tree[v][0] + tree[v][1])
        return tree[v][0]
    if r < ql or qr < l:
        return 2000000000
    m = (l + r) // 2
    ansl = get(2 * v, l, m, ql, qr)
    ansr = get(2 * v + 1, m + 1, r, ql, qr)
    return tree[v][1] + min(ansl, ansr)


n = int(input())
a = list(map(int, input().split()))
a += a
build(1, 0, 2 * n - 1)
m = int(input())
for i in range(m):
    qwe = list(map(int, input().split()))
    if len(qwe) == 2:
        l, r = qwe[0], qwe[1]
        if r < l:
            r += n
        print(get(1, 0, 2 * n - 1, l, r))
    else:
        l, r, x = qwe[0], qwe[1], qwe[2]
        if r < l:
            update(1, 0, 2 * n - 1, l, r + n, x)
            update(1, 0, 2 * n - 1, 0, r, x)
            update(1, 0, 2 * n - 1, l + n, 2 * n - 1, x)
        else:
            update(1, 0, 2 * n - 1, l, r, x)
            update(1, 0, 2 * n - 1, l + n, r + n, x)

# Wed Jul 12 2023 19:02:08 GMT+0300 (Moscow Standard Time)
