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.

from math import inf, log2, ceil

def tmp(v,z,segtree):
    if 2*v<len(segtree)-2:
        segtree[2*v+1]+=z[v]
        segtree[2*v+2]+=z[v]
        z[2*v+1]+=z[v]
        z[2*v+2]+=z[v]
        z[v]=0

def create_segtree(arr,v,l,r,segtree):
    if l==r:
        segtree[v] = arr[l]
    else:
        m = (l+r)//2
        create_segtree(arr,2*v+1,l,m,segtree)
        create_segtree(arr,2*v+2,m+1,r,segtree)
        segtree[v] = min(segtree[2*v+1], segtree[2*v+2])

def min_segtree(segtree,v,l,r,ql,qr,z):
    if ql>r or qr<l:
        return inf
    elif l>=ql and r<=qr:
        return segtree[v]
    else:
        tmp(v,z,segtree)
        m = (l+r)//2
        return min(min_segtree(segtree,2*v+1,l,m,ql,qr,z), min_segtree(segtree,2*v+2,m+1,r,ql,qr,z))

def update_segtree(segtree,v,l,r,ql,qr,val,z):
    if ql>r or qr<l:
        return
    if l>=ql and r<=qr:
        segtree[v]+=val
        z[v]+=val
    else:
        tmp(v,z,segtree)
        m = (l+r)//2
        update_segtree(segtree,2*v+1,l,m,ql,qr,val,z)
        update_segtree(segtree,2*v+2,m+1,r,ql,qr,val,z)
        segtree[v] = min(segtree[2*v+1], segtree[2*v+2])

n=int(input())
arr=list(map(int, input().split()))
segtree=[0 for _ in range(2**(ceil(log2(n))+1)-1)]
z=[0 for _ in range(2**(ceil(log2(n))+1)-1)]
create_segtree(arr,0,0,n-1,segtree)
q=int(input())
for _ in range(q):
    x=list(map(int, input().split()))
    if len(x)==3:
        [ql,qr,val]=x
        if ql>qr:
            update_segtree(segtree,0,0,n-1,0,qr,val,z)
            update_segtree(segtree,0,0,n-1,ql,n-1,val,z)
        else:
            update_segtree(segtree,0,0,n-1,ql,qr,val,z)
    elif len(x)==2:
        [ql,qr]=x
        if ql>qr:
            print(min(min_segtree(segtree,0,0,n-1,0,qr,z),min_segtree(segtree,0,0,n-1,ql,n-1,z)))
        else:
            print(min_segtree(segtree,0,0,n-1,ql,qr,z))




