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]*(4*200005)
lazy=[0]*(4*200005)

def build(ind, low, high, v):
    if low==high:
        seg[ind]=v[low]
        return
    mid=(low+high)//2
    build(2*ind+1, low, mid, v)
    build(2*ind+2, mid+1, high, v)
    seg[ind]=min(seg[2*ind+1], seg[2*ind+2])

def rangeUpdate(ind, low, high, l, r, val):
    if lazy[ind]!=0:
        seg[ind]+=(high-low+1)*lazy[ind]
        if low!=high:
            lazy[2*ind+1]+=lazy[ind]
            lazy[2*ind+2]+=lazy[ind]
        lazy[ind]=0

    if r<low or l>high or low>high:
        return
    
    if low>=l and high<=r:
        seg[ind]+=(high-low+1)*val
        if low!=high:
            lazy[2*ind+1]+=val
            lazy[2*ind+2]+=val
        return

    mid=(low+high)//2
    rangeUpdate(2*ind+1, low, mid, l, r, val)
    rangeUpdate(2*ind+2, mid+1, high, l, r, val)
    seg[ind]=min(seg[2*ind+1],seg[2*ind+2])

def querySumLazy(ind, low, high, l, r):
    if lazy[ind]!=0:
        seg[ind]+=(high-low+1)*lazy[ind]
        if low!=high:
            lazy[2*ind+1]+=lazy[ind]
            lazy[2*ind+2]+=lazy[ind]
        lazy[ind]=0

    if r<low or l>high or low>high:
        return 1000000
    
    if low>=l and high<=r:
        return seg[ind]
    
    mid=(low+high)//2
    left=querySumLazy(2*ind+1, low, mid, l, r)
    right=querySumLazy(2*ind+2, mid+1, high, l, r)
    return min(left, right)

n=int(input())
v=list(map(int,input().split()))
build(0,0,n-1,v)
q=int(input())
while q:
    q-=1
    l=list(map(int, input().split()))
    # print(l)
    if(len(l)==2):
        if(l[0]<=l[1]):
            print(querySumLazy(0,0,n-1,l[0],l[1]))
        else:
            print(min(querySumLazy(0,0,n-1,l[0],n-1), querySumLazy(0,0,n-1,0,l[1])))
    else:
        if(l[0]<=l[1]):
            rangeUpdate(0,0,n-1,l[0],l[1],l[2])
        else:
            rangeUpdate(0,0,n-1,l[0],n-1,l[2])
            rangeUpdate(0,0,n-1,0,l[1],l[2])
