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 ceil, log2
def inc(segment, lazy, fr, to, value, L, R, index):
    
    if(R < L):
        return INF 
    if(lazy[index] != 0):
        segment[index] += lazy[index]
        if(L != R):
            lazy[index*2+1] += lazy[index]
            lazy[index*2+2] += lazy[index]
        lazy[index] = 0
    
    if(to < L or R< fr):
        return INF 
    
    elif(fr <= L and to >= R):
        segment[index]+= value
        if(L!= R):
            lazy[index*2 +1] += value 
            lazy[index*2 +2] += value
        return segment[index]
    else:
        mid = (L +R) //2 
        u =inc(segment, lazy, fr, to, value, L, mid, index*2+1)
        v = inc(segment, lazy, fr, to, value, mid+ 1, R, index*2+2)
        segment[index] = min(u,v)
        return segment[index]
            
    
    
def RMQ(segment, lazy, fr, to, L, R , index):
    
    # -- L ---fr  --to-R
    
    if(L >R):
        return INF
    
    if(lazy[index] != 0):
        segment[index] += lazy[index]
        if(L != R):
            lazy[index*2+1] += lazy[index]
            lazy[index*2+2] += lazy[index]
        lazy[index] = 0 
    
    if(to < L or R < fr):
        return INF 
    elif(fr <= L and to >= R):
        return segment[index]
        
    
    else:
            
        mid = (L + R) //2 
        u = RMQ(segment, lazy, fr, to, L,mid , 2* index+ 1)
        
        v = RMQ(segment, lazy, fr, to, mid + 1,R , 2* index+ 2)
        
        segment[index] = min(u, v)
        return segment[index]
    

def buildTree(segment, a, L ,R, index):
    
    
    if(L ==R) :
        segment[index] = a[L]
        return segment[index] 
    mid= (L + R) //2 
    u = buildTree(segment, a,L ,mid , 2* index + 1 ) 
    v =     buildTree(segment,a, mid + 1 ,R, 2* index + 2)
    segment[index] = min(u, v)
    return segment[index]


if __name__ == '__main__':
    
    INF = 1e9
    n = int(input())
    
    a = list(map(int, input().split()))
    
    # for i in range(0, n-1, 1):
    #     a.append(a[i])
    # print(a)
    size = (2*( 2**  (ceil(log2( len(a) )  )) ) - 1)
    segment = [INF] * size
    lazy = [0] * size
    
    buildTree(segment,a, 0 , len(a) -1, 0)
    # print(segment)
    Q = int(input())
    
    for _ in range(Q):
        
        info = list(map(int, input().split()))
        
        if(len(info) == 2):
            fr,to = info[0], info[1]
            # ans = INF
            if(fr > to):
                # print('0sdfdf', to, len(a)-1) ## 3  fr -- 0to
                u = RMQ(segment, lazy, fr, len(a) -1, 0, len(a) -1 , 0)
                # print('1dfdffd',0, fr)
                v = RMQ(segment, lazy, 0, to, 0, len(a) -1 , 0)
                ans = min(u, v)
                print(ans)
            else:
                
                ans = RMQ(segment, lazy, fr, to, 0, len(a) -1 , 0)
                print(ans)
            # print(ans)
            
        else:
            
            fr, to , value = info[0],info[1], info[2]
    
            
            if(fr > to):
                # print('0 dfdf', to, len(a)-1)
                u = inc(segment, lazy, fr, len(a) -1, value, 0, len(a) -1, 0)
                # print('1df df' ,0, fr)
                v = inc(segment, lazy, 0, to, value, 0, len(a) -1, 0)
                
            else:    
                inc(segment, lazy, fr, to, value, 0, len(a) -1, 0)
    
    
    