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.
class stree:
    def __init__(self, n):
        self.n = n
        self.tree = [0]*(4*n+1)
        self.delta = [0]*(4*n+1)
    
    def prop(self, i):
        self.delta[2*i] += self.delta[i]
        self.delta[2*i+1] += self.delta[i]
        self.delta[i] = 0
    
    def update(self, i):
        self.tree[i] = min(self.tree[2*i]+self.delta[2*i], self.tree[2*i+1]+self.delta[2*i+1])
    
    def incr(self, node, i, j, l, r, val):
        if i > r or j < l:
            return
        if i <= l and j >= r:
            self.delta[node] += val
            #print(val,"added to", node)
            return
        self.prop(node)
        mid = (l+r)//2
        self.incr(2*node, i, j, l, mid, val)
        self.incr(2*node+1, i, j, mid+1, r, val)
        self.update(node)
        
    def query(self, node, i, j, l, r):
        if i > r or j < l:
            return 10**7
        if i <= l and j <= r:
            return self.delta[node]+self.tree[node]
        self.prop(node)
        mid = (l+r)//2
        left = self.query(2*node, i, j, l, mid)
        right = self.query(2*node+1, i, j, mid+1, r)
        return min(left, right)

n = int(input().strip())
arr = list(map(int, input().strip().split()))
i = 0
st = stree(n)
while i<n:
    st.incr(1, i, i, 0, n-1, arr[i])
    i += 1

q = int(input().strip())
#print(st.tree," and ", st.delta)
while q:
    a = list(map(int, input().strip().split()))
    if len(a) == 2:
        if a[0] <= a[1]:
            print(st.query(1, a[0], a[1], 0, n-1))
        else:
            print(min(st.query(1, a[0], n-1, 0, n-1), st.query(1, 0, a[1], 0, n-1)))
    else:
        if a[0] <= a[1]:
            st.incr(1, a[0], a[1], 0, n-1, a[2])
        else:
            st.incr(1, a[0], n-1, 0, n-1, a[2])
            st.incr(1, 0, a[1], 0, n-1, a[2])
    
    q -= 1