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.
from math import inf


class SegmentTree:
    l, r, val, push_l, push_r, push_val, left, right = 0, 0, 0, 0, 0, 0, None, None

    def __init__(self, l: int, r: int, a: list):
        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):
        if self.r < ql or self.l > qr:
            return inf

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

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

    def seg_upd(self, ql, qr, inc):
        if self.r < ql or self.l > qr:
            return inf

        if self.l == self.r:
            self.val += inc
            return

        self.left.seg_upd(ql, qr, inc)
        self.right.seg_upd(ql, qr, inc)

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


def main():
    n = int(input())

    a = list(map(int, input().split()))

    tree = SegmentTree(0, n - 1, a)

    m = int(input())

    for i in range(m):
        query = list(map(int, input().split()))

        q_type = "inc" if len(query) == 3 else "get"

        lf, rg = query[0], query[1]

        inc = 0
        if q_type == "inc":
            inc = query[2]

        if lf > rg:
            if q_type == "get":
                print(min(tree.get(0, rg), tree.get(lf, n - 1)))
            else:
                tree.seg_upd(0, rg, inc)
                tree.seg_upd(lf, n - 1, inc)
        else:
            if q_type == "get":
                print(tree.get(lf, rg))
            else:
                tree.upd(lf, rg, inc)


if __name__ == '__main__':
    main()
