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.

seg = [0] * (800005)
lazy = [0] * (800005)
inf = 10000000

def build(ind,st,end):
    if(st > end):
        return

    if(st == end):
        seg[ind] = l[st]
        return

    mid = (st + end)//2

    build(2*ind,st,mid)
    build(2*ind + 1,mid + 1,end)

    seg[ind] = min(seg[2*ind],seg[2*ind + 1])



def rupdate(ind,st,end,lt,rt,val):

    if(st > end or st > rt or end < lt):
        return


    if(lazy[ind] != 0):
        seg[ind] += (end - st + 1) * lazy[ind]
        if(st != end):
            lazy[2*ind] += lazy[ind]
            lazy[2*ind + 1] += lazy[ind]

        lazy[ind] = 0




    if(st >= lt and end <= rt):
        seg[ind] += (end - st + 1)*val

        if(st != end):
            lazy[2*ind] += val
            lazy[2*ind + 1] += val


        return



    mid = (st + end)//2
    rupdate(2*ind,st,mid,lt,rt,val)
    rupdate(2*ind + 1,mid + 1,end,lt,rt,val)

    seg[ind] = min(seg[2*ind],seg[2*ind + 1])




def query(ind,st,end,lt,rt):

    if(st > rt or end < lt):
        return inf


    if(lazy[ind] != 0):
        seg[ind] += (end - st + 1) * lazy[ind]

        if(st != end):
            lazy[2*ind] += lazy[ind]
            lazy[2*ind + 1] += lazy[ind]

        lazy[ind] = 0

    if(st >= lt and end <= rt):
        return seg[ind]


    mid = (st + end)//2

    x = query(2*ind,st,mid,lt,rt)
    y = query(2*ind + 1,mid+1,end,lt,rt)

    return min(x,y)





n = int(input())
l = list(map(int ,input().split()))
build(1,0,n-1)
m = int(input())
for _ in range(m):
    li = list(map(int ,input().split()))
    if(len(li) == 2):
        if(li[0] > li[1]):
            ans1 = query(1,0,n-1,li[0],n-1)
            ans2 = query(1,0,n-1,0,li[1])
            print(min(ans1,ans2))

        else:
            ans = query(1,0,n-1,li[0],li[1])
            print(ans)

    else:
        if(li[0] > li[1]):
            rupdate(1,0,n-1,li[0],n-1,li[2])
            rupdate(1, 0, n - 1,0, li[1],li[2])

        else:
            rupdate(1,0,n-1,li[0],li[1],li[2])