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 SegmentTree():

    def __init__(self, n):
        self.n  = n+1
        self.tree =     [0]*(n*2)
        self.delta =    [0]*(n*2)
        self.hi =       [0]*(n*2)
        self.lo =       [0]*(n*2)
        self.build()


    def incrementRange(self, a, b, val, index = 1):
        if b < self.lo[index] or a > self.hi[index]:
            return
        elif a <= self.lo[index] and b >= self.hi[index]:
            self.delta[index] += val
            return

        self.prop(index)
        self.incrementRange(a,b,val,index*2)
        self.incrementRange(a,b,val,index*2+1)
        self.update(index)
        return

    def rangeQuery(self, a,b, index = 1):
        if b < self.lo[index] or a > self.hi[index]:
            return float("inf")
        elif a <= self.lo[index] and b >= self.hi[index]:
            return self.tree[index] + self.delta[index]

        self.prop(index)
        minLeft =   self.rangeQuery(a,b,index*2)
        minRight =  self.rangeQuery(a,b,index*2+1)
        self.update(index)
        return min(minLeft, minRight)

    def prop(self, index):
        #pushes delta to children
        if index*2+1 < len(self.delta):
            self.delta[index*2]     += self.delta[index]
            self.delta[index*2+1]   += self.delta[index]
            self.delta[index]       = 0
        #If at leaf node process delta update
        else:
            self.tree[index] += self.delta[index]
            self.delta[index] = 0

    def update(self, index):
        if index*2+1 < len(self.delta):
            self.tree[index] = min(self.tree[index*2] + self.delta[index*2], self.tree[index*2+1] + self.delta[index*2+1])

    def build(self):
        self.hi[1] = self.n -1
        self.lo[1] = 1
        n = len(self.hi)
        for i in range(1, self.n):
            if (i*2 + 1) < n:
                m = (self.hi[i] + self.lo[i]) //2
                self.hi[i*2] = m
                self.lo[i*2] = self.lo[i]
                self.hi[i*2 + 1] = self.hi[i]
                self.lo[i*2 + 1] = m+1
            else:
                break
        #print(self.hi)
        #print(self.lo)

def main():
    from sys import stdin

    n = int(stdin.readline())
    arr = [int(val) for val in stdin.readline().strip().split()]
    st = SegmentTree(len(arr))
    for i,val in enumerate(arr,start = 1):
        st.incrementRange(i,i,val)
    _ = stdin.readline()
    for line in stdin:
        inp = [int(val) for val in line.split()]
        if len(inp) == 2:
            a,b = inp
            a += 1
            b += 1
            if a <= b:
                print(st.rangeQuery(a,b))
            else:
                tmp1 = st.rangeQuery(a,n)
                tmp2 = st.rangeQuery(1,b)
                print(min(tmp1,tmp2))
        else:
            a,b,val = inp
            a += 1
            b += 1
            if a <= b:
                st.incrementRange(a,b,val)
            else:
                st.incrementRange(a,n,val)
                st.incrementRange(1,b,val)

if __name__ == "__main__":
    main()
