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.
# yash490
# Segment Tree with lazy propogation

import sys
sys.setrecursionlimit(int(1e4))
def buildTree(v, lr, rr):
    if lr == rr:
        segT[v] = lis[lr]
        return 
    mid = (rr + lr) // 2
    buildTree(2 * v + 1, lr, mid)
    buildTree(2 * v + 2, mid + 1, rr)
    segT[v] = min(segT[2 * v + 1], segT[2 * v + 2])
    
def push(v):
    lazy[2 * v + 1] = lazy[v]
    lazy[2 * v + 2] = lazy[v]
    lazy[v] = 0
    
def inc(v, lr, rr, l, r, num):
    if l > rr or r < lr:
        return 
    if l == lr and r == rr:
        segT[v] += num
        lazy[v] += num
        return
    push(v)
    mid = (lr + rr) // 2
    inc(2 * v + 1, lr, mid, l, r, num)
    inc(2 * v + 2, mid + 1, rr, l, r, num)
    segT[v] = min(segT[2 * v + 1], segT[2 * v + 2])
     
def rmq(v, lr, rr, l, r):
    if l > rr or r < lr:
        return float('inf')
    if l == lr and r == rr:
        return segT[v]
    push(v)
    mid = (lr + rr) // 2
    ans1 = rmq(2 * v + 1, lr, mid, l, r)
    ans2 = rmq(2 * v + 2, mid + 1, rr, l, r)
    return min(ans1, ans2)

n = int(input())
lis = list(map(int, input(). split()))
segT = [None] * (4 * n)
buildTree(0, 0, n - 1) # build the segment tree
lazy = [0 for i in range(4 * n)]
for q in range(int(input())):
    inp = list(map(int, input(). split()))
    if len(inp) == 3:
        #inc oper
        lf, rg, num = inp[0], inp[1], inp[2]
        if lf > rg:
            inc(0, 0, n - 1, lf, n - 1, num) # lf to n - 1
            inc(0, 0, n - 1, 0, rg, num) # 0 to rf
        
        else:
            inc(0, 0, n - 1, lf, rg, num) # lf to rf
            
    elif len(inp) == 2:
        #rmq oper
        lf, rg = inp[0], inp[1]
        if lf > rg:
            ans1 = rmq(0, 0, n - 1, lf, n - 1) # lf to n - 1
            ans2 = rmq(0, 0, n - 1, 0, rg) # 0 to rg
            print(min(ans1, ans2))
        else:
            ans = rmq(0, 0, n - 1, lf, rg) # lf to rf
            print(ans)