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.
INF = 10 ** 9


class LazySegmentTree:
    def __init__(self, n):
        self.base = 1
        while self.base < n:
            self.base *= 2
        self.tree = [0] * (self.base * 2)
        self.lazy = [0] * (self.base * 2)

    def _flush(self, pos):
        if self.lazy[pos] != 0:
            self.tree[pos] += self.lazy[pos]
            if pos < self.base:
                self.lazy[2 * pos] += self.lazy[pos]
                self.lazy[2 * pos + 1] += self.lazy[pos]
            self.lazy[pos] = 0

    def _rmq(self, l, r, nl, nr, pos):
        self._flush(pos)
        if max(l, nl) > min(r, nr):
            return INF
        if l <= nl and nr <= r:
            return self.tree[pos]
        mid = (nl + nr) // 2
        return min(self._rmq(l, r, nl, mid, 2 * pos), self._rmq(l, r, mid + 1, nr, 2 * pos + 1))

    def rmq(self, l, r):
        return self._rmq(l, r, 0, self.base - 1, 1)

    def _inc(self, l, r, delta, nl, nr, pos):
        self._flush(pos)
        if max(l, nl) > min(r, nr):
            return
        if l <= nl and nr <= r:
            self.lazy[pos] = delta
            self._flush(pos)
            return
        mid = (nl + nr) // 2
        self._inc(l, r, delta, nl, mid, 2 * pos)
        self._inc(l, r, delta, mid + 1, nr, 2 * pos + 1)
        self.tree[pos] = min(self.tree[2 * pos], self.tree[2 * pos + 1])

    def inc(self, l, r, delta):
        self._inc(l, r, delta, 0, self.base - 1, 1)


n = int(input())
arr = LazySegmentTree(n)
a = list(map(int, input().split()))
for i, e in enumerate(a):
    arr.inc(i, i, e)
m = int(input())
for _ in range(m):
    t = tuple(map(int, input().split()))
    l, r = t[0], t[1]
    if len(t) == 2:
        if l <= r:
            print(arr.rmq(l, r))
        else:
            print(min(arr.rmq(0, r), arr.rmq(l, n - 1)))
    else:
        v = t[2]
        if l <= r:
            arr.inc(l, r, v)
        else:
            arr.inc(0, r, v)
            arr.inc(l, n - 1, v)