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.
def new_no(a):
    return a

def combineM(l,r):
    return min(l,r)

def combineS(l,r):
    return l+r

def combineLazy(seg,laz):
    return seg+laz

def acumulaLazy(id,v):
    global lazy
    lazy[id]+=v

def propaga(id,l,r):
    global treeS,treeM,lazy
    treeS[id] = combineLazy(treeS[id],lazy[id]*(r-l+1))
    treeM[id] = combineLazy(treeM[id],lazy[id])
    if(l!=r):
        acumulaLazy(id<<1,lazy[id])
        acumulaLazy((id<<1)+1,lazy[id])
    lazy[id] = 0
    
def build(id,l,r):
    global treeS,treeM,lazy
    if(l == r):
        treeS[id] = new_no(ar[l])
        treeM[id] = new_no(ar[l])
        lazy[id] = 0
    else:
        mid = (l+r)//2
        build(id<<1,l,mid)
        build((id<<1)+1,mid+1,r)
        treeS[id] = combineS(treeS[id<<1],treeS[(id<<1)+1])
        treeM[id] = combineM(treeM[id<<1],treeM[(id<<1)+1])
        lazy[id] = 0

def update(id,l,r,ini,fin,v):
    global treeS,treeM,lazy
    mid = (l+r)//2
    if(l>fin or r<ini):
        propaga(id,l,r)
    elif(l == ini and r == fin):
        acumulaLazy(id,v)
        propaga(id,l,r)
    else:
        propaga(id,l,r)
        update(id<<1,l,mid,ini,min(mid,fin),v)
        update((id<<1)+1,mid+1,r,max(mid+1,ini),fin,v)
        
        treeS[id] = combineS(treeS[id<<1],treeS[(id<<1)+1])
        treeM[id] = combineM(treeM[id<<1],treeM[(id<<1)+1])

def query(id,l,r,ini,fin):
    global treeS,treeM,lazy
    propaga(id,l,r)
    
    if(l>fin or r<ini):
        return INF
    elif(l>=ini and fin>=r):
        return treeM[id]
    
    mid = (l+r)//2
    return combineM(query(id<<1,l,mid,ini,min(mid,fin)),query((id<<1)+1,mid+1,r,max(mid+1,ini),fin))
    
MAXN = int(1e6)+1

treeS = [0]*4*MAXN
treeM = [0]*4*MAXN
lazy = [0]*4*MAXN
INF = 10000000000000000000000000000000000000

n = int(input())
ar = [int(i) for i in input().split()]
ar.insert(0,INF)
q = int(input())

build(1,1,n)

while(q>0):

    inp = [int(i) for i in input().split()]

    if(len(inp) == 2):
    
        if(inp[0]>inp[1]): 
            print(combineM(query(1,1,n,inp[0]+1,n),query(1,1,n,1,inp[1]+1)))
        else:
            print(query(1,1,n,inp[0]+1,inp[1]+1))
    else:
    
        if(inp[0]>inp[1]):
            update(1,1,n,inp[0]+1,n,inp[2])
            update(1,1,n,1,inp[1]+1,inp[2])
        else:
            update(1,1,n,inp[0]+1,inp[1]+1,inp[2])

    q-=1




	  	 		 	 		  				 		 	 		   	