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:
    class Node:
        __slots__ = ('low', 'high', 'agg', 'delta')
        def __init__(self, low, high):
            self.low = low
            self.high = high
            self.agg = 0
            self.delta = 0
        def eval(self):
            return self.agg + self.delta
        def __str__(self):
            return f'[{self.low}, {self.high}] {self.agg} + {self.delta}'

    __slots__ = ('n', 'nodes')

    def __init__(self, n=None, values=None):
        if n is None and values is None:
            raise "Error: Either n or values must be specified"
        self.n = n if values is None else len(values)
        self.nodes = [self.Node(None, None) for _ in range(4 * self.n + 1)]
        self._init(1, 0, self.n - 1)
        if values:
            for i, value in enumerate(values):
                self.increment(i, i, value)
    
    def increment(self, a, b, v):
        self._increment(1, a, b, v)

    def aggregate(self, a, b):
        return self._aggregate(1, a, b)

    def _init(self, i, a, b):
        node = self.nodes[i]
        node.low = a
        node.high = b

        if a == b:
            return

        m = (a + b) // 2
        self._init(i * 2, a, m)
        self._init(i * 2 + 1, m + 1, b)

    def _prop(self, i):
        node = self.nodes[i]
        self.nodes[i * 2].delta += node.delta
        self.nodes[i * 2 + 1].delta += node.delta
        node.delta = 0

    def _update(self, i):
        self.nodes[i].agg = min(self.nodes[i * 2].eval(), self.nodes[i * 2 + 1].eval())

    def _increment(self, i, a, b, v):
        node = self.nodes[i]
        if node.high < a or b < node.low:
            return
        if a <= node.low and node.high <= b:
            node.delta += v
            return
        
        self._prop(i)
        self._increment(i * 2, a, b, v)
        self._increment(i * 2 + 1, a, b, v)
        self._update(i)
    
    def _aggregate(self, i, a, b):
        node = self.nodes[i]
        if node.high < a or b < node.low:
            return float('inf')
        if a <= node.low and node.high <= b:
            return node.eval()
        
        self._prop(i)
        min_l = self._aggregate(i * 2, a, b)
        min_r = self._aggregate(i * 2 + 1, a, b)
        self._update(i)

        return min(min_l, min_r)

    def print(self, i=1, depth=0):
        node = self.nodes[i]
        print([str(node) for node in self.nodes])
        print('\t' * depth + str(node))
        if node.low == node.high:
            return
        self.print(i * 2, depth + 1)
        self.print(i * 2 + 1, depth + 1)
            
if __name__ == '__main__':
    N = int(input())
    values = [int(x) for x in input().split()]
    tree = SegmentTree(values=values)
    M = int(input())
    for m in range(M):
        l, r, *V = [int(x) for x in input().split()]
        if V:
            v = V[0]
            if l > r:
                tree.increment(0, r, v)
                tree.increment(l, N - 1, v)
            else:
                tree.increment(l, r, v)
        else:
            if l > r:
                print(min(tree.aggregate(0, r), tree.aggregate(l, N - 1)))
            else:
                print(tree.aggregate(l, r))
