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:
    l, r, val, push_l, push_r, push_val, inf, left, right = 0, 0, 0, 0, 0, 0, 10 ** 18, None, None

    def __init__(self, l, r, a):
        self.l = l
        self.r = r

        if self.l == self.r:
            self.val = a[l]
            return

        m = (self.l + self.r) // 2
        self.left = SegmentTree(l, m, a)
        self.right = SegmentTree(m + 1, r, a)

        self.val = min(self.left.val, self.right.val)

    def get(self, ql, qr):
        self.push()

        if self.r < ql or self.l > qr:
            return self.inf

        if ql <= self.l and qr >= self.r:
            return self.val

        return min(self.left.get(ql, qr), self.right.get(ql, qr))

    def seg_update(self, ql, qr, up):
        self.push()

        self.push_l = ql
        self.push_r = qr
        self.push_val = up

        self.push()

    def update(self, pos, new_val):
        if self.l == self.r:
            self.val = new_val
            return

        m = (self.l + self.r) // 2
        if pos <= m:
            self.left.update(pos, new_val)
        else:
            self.right.update(pos, new_val)

        self.val = min(self.left.val, self.right.val)

    def push(self):
        if self.push_val == 0:
            return

        if not (self.r < self.push_l or self.l > self.push_r):
            self.val += self.push_val * (min(self.r, self.push_r) - max(self.l, self.push_l) + 1)
            if self.left:
                self.left.push_l, self.left.push_r, self.left.push_val = self.push_l, self.push_r, self.push_val
            if self.right:
                self.right.push_l, self.right.push_r, self.right.push_val = self.push_l, self.push_r, self.push_val

        self.push_l = 0
        self.push_r = 0
        self.push_val = 0


def solve():
    n = int(input())
    a = [int(i) for i in input().split()]
    tree = SegmentTree(0, n - 1, a)

    m = int(input())
    for i in range(m):
        q = [int(i) for i in input().split()]
        if len(q) == 2:
            l, r = q[0], q[1]
            if l > r:
                print(min(tree.get(0, r), tree.get(l, n - 1)))
            else:
                print(tree.get(l, r))
        else:
            l, r, val = q[0], q[1], q[2]
            if l > r:
                tree.seg_update(0, r, val)
                tree.seg_update(l, n - 1, val)
            else:
                tree.seg_update(l, r, val)


solve()
