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.
import sys

val=[0]*550001
upd=[0]*550001
l=[0]*550001
r=[0]*550001
k=1

def build(a,n):
    global k
    while k<n:
        k*=2
    for i in range(k):
        l[i+k]=i
        r[i+k]=i
    for i in range(k-1,0,-1):
        l[i]=l[2*i]
        r[i]=r[2*i+1]
    for i in range(n):
        val[i+k]=a[i]
    for i in range(k-1,0,-1):
        val[i]=min(val[2*i],val[2*i+1])

def update(p):
    global k
    val[p]+=upd[p]
    if p<k:
        upd[2*p]+=upd[p]
        upd[2*p+1]+=upd[p]
    upd[p]=0

def add(p,ll,rr,x):
    if ll>r[p] or rr<l[p]:
        update(p)
    elif ll<=l[p] and rr>=r[p]:
        upd[p]+=x
        update(p)
    else:
        update(p)
        add(2*p,ll,rr,x)
        add(2*p+1,ll,rr,x)
        val[p]=min(val[2*p],val[2*p+1])

def rmq(p,ll,rr):
    if ll>r[p] or rr<l[p]:
        return 1608199929042004420
    if ll<=l[p] and rr>=r[p]:
        update(p)
        return val[p]
    else:
        update(p)
        return min(rmq(2*p,ll,rr),rmq(2*p+1,ll,rr))

def main():
    n=int(sys.stdin.readline())
    a=list(map(int,sys.stdin.readline().split()))
    build(a,n)

    q=int(sys.stdin.readline())
    for i in range(q):
        kveri=list(map(int,sys.stdin.readline().split()))
        if (len(kveri)==2):
            odg=0
            if kveri[0]>kveri[1]:
                odg=min(rmq(1,kveri[0],n-1),rmq(1,0,kveri[1]))
            else:
                odg=rmq(1,kveri[0],kveri[1])
            sys.stdout.write(str(odg)+'\n')
        else:
            if kveri[0]>kveri[1]:
                add(1,kveri[0],n-1,kveri[2])
                add(1,0,kveri[1],kveri[2])
            else:
                add(1,kveri[0],kveri[1],kveri[2])

main()
