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 SegTree:
    def __init__(self, sz):
        self.size = sz
        self.t = [self.e()] * (self.size << 2)
        self.lazy = [0] * (self.size << 2)
    
    def e(self):
        return 1000001
    
    def push(self, v):
        self.t[(v << 1)] += self.lazy[v]
        self.t[(v << 1) | 1] += self.lazy[v]
        self.lazy[v << 1] += self.lazy[v]
        self.lazy[(v << 1) | 1] += self.lazy[v]
        self.lazy[v] = 0
    
    def op(self, a, b):
        return min(a, b)

    def build(self, src, tl = 0, tr = -1, v = 1):
        if(tr == -1):
            tr = self.size - 1
        
        if(tl == tr):
            self.t[v] = src[tl]
            return
        tm = (tl + tr) >> 1
        self.build(src, tl, tm, v << 1)
        self.build(src, tm + 1, tr, (v << 1) | 1)
        self.t[v] = self.op(self.t[v << 1], self.t[(v << 1) | 1])
    
    def query(self, l, r, tl = 0, tr = -1, v = 1):
        if(tr == -1):
            tr = self.size - 1
        
        if(l > r):
            return self.e()
        if(l == tl and r == tr):
            return self.t[v]
        tm = (tl + tr) >> 1
        self.push(v)
        return self.op(self.query(l, min(r, tm), tl, tm, v << 1), self.query(max(l, tm + 1), r, tm + 1, tr, (v << 1) | 1))

    def update(self, l, r, add, tl = 0, tr = -1, v = 1):
        if(tr == -1):
            tr = self.size - 1

        if(l > r):
            return
        if(l == tl and r == tr):
            self.t[v] += add
            self.lazy[v] += add
            return
        tm = (tl + tr) >> 1
        self.push(v)
        self.update(l, min(r, tm), add, tl, tm, v << 1)
        self.update(max(l, tm + 1), r, add, tm + 1, tr, (v << 1) | 1)
        self.t[v] = self.op(self.t[v << 1], self.t[(v << 1) | 1])

n = int(input())
a = list(map(int, input().split(" ")))
m = int(input())
segtree = SegTree(n)
segtree.build(a)

for _ in range(m):
    params = list(map(int, input().split(" ")))

    if(len(params) == 2):
        # RMQ
        lf, rg = params
        if(lf <= rg):
            print(segtree.query(lf, rg))
        else:
            print(min(segtree.query(lf, segtree.size - 1), segtree.query(0, rg)))
    else:
        # INC
        lf, rg, v = params
        if(lf <= rg):
            segtree.update(lf, rg, v)
        else:
            segtree.update(lf, segtree.size - 1, v)
            segtree.update(0, rg, v)