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.
N=800010
inf=100000000000
seg=[0]*N
lazy=[0]*N

def build(curr,st,end,l):
    if(st==end):
        seg[curr]=l[st]
        return
    mid=(st+end)//2;
    build(curr*2+1,st,mid,l)
    build(curr*2+2,mid+1,end,l)
    if(st!=end):
        seg[curr]=min(seg[curr*2+1],seg[curr*2+2]);

def solvelazy(curr,st,end):
    seg[curr]+=lazy[curr]
    if(st!=end):
        lazy[curr*2+1]+=lazy[curr]
        lazy[curr*2+2]+=lazy[curr]
    lazy[curr]=0

def update(curr,st,end,l,r,value):
    solvelazy(curr,st,end)
    if(st>r or end<l):
        return
    if(st>=l and end<=r):
        lazy[curr]+=value
        solvelazy(curr,st,end);
        return 
    mid=(st+end)//2;
    update(curr*2+1,st,mid,l,r,value);
    update(curr*2+2,mid+1,end,l,r,value)
    if(st!=end):
        seg[curr]=min(seg[curr*2+1],seg[curr*2+2]);

def query(curr,st,end,l,r):
    solvelazy(curr,st,end)
    if(st>r or end<l):
        return inf
    if(st>=l and end<=r):
        return seg[curr]
    mid=(st+end)//2;
    ans=min(query(curr*2+1,st,mid,l,r),query(curr*2+2,mid+1,end,l,r))
    if(st!=end):
        seg[curr]=min(seg[curr*2+1],seg[curr*2+2]);
    return ans
def main():
    n=int(input())
    l=list(map(int,input().split()))
    build(0,0,n-1,l)
    q=int(input())
    for _ in range(q):
        que=list(map(int,input().split()))
        if(len(que)==2):
            l=que[0]
            r=que[1]
            if(r>=l):
                ans=query(0,0,n-1,l,r)
                print(ans)
            else:
                ans=min(query(0,0,n-1,l,n-1),query(0,0,n-1,0,r))
                print(ans)
        else:
            l=que[0]
            r=que[1]
            value=que[2]
            if(r>=l):
                update(0,0,n-1,l,r,value);
            else:
                update(0,0,n-1,l,n-1,value);
                update(0,0,n-1,0,r,value);
                
    
main()