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.
import sys


readline = sys.stdin.readline
data = []
ops = []

class SegTree:
    def __init__(self, data: list):
        n = len(data)
        m = 1
        while m < n:
            m += m
        self.low = [0x3f3f3f3f] * (m * 2 + 1)
        self.high = [-0x3f3f3f3f] * (m * 2 + 1)
        self.min = [0x3f3f3f3f] * (m * 2 + 1)
        self.lazy = [0] * (m * 2 + 1)

        for i in range(n):
            self.high[m + i] = self.low[m + i] = i
            self.min[m + i] = data[i]
        for i in range(m + n - 1, 1, -1):
            self.min[i//2] = min(self.min[i//2], self.min[i])
            self.low[i//2] = min(self.low[i//2], self.low[i])
            self.high[i//2] = max(self.high[i//2], self.high[i])


    def push_down(self, idx: int):
        if self.lazy[idx] == 0:
            return
        left = idx * 2
        right = idx * 2 + 1
        self.min[left] += self.lazy[idx]
        self.min[right] += self.lazy[idx]
        self.lazy[left] += self.lazy[idx]
        self.lazy[right] += self.lazy[idx]
        self.lazy[idx] = 0

    def update(self, idx:int,  low:int , high: int, inc: int):
        if self.low[idx] > high or self.high[idx] < low:
            return
        if self.low[idx] == self.high[idx]:
            self.min[idx] +=  inc
            return

        if low <= self.low[idx] and self.high[idx] <= high:
            self.min[idx] += inc
            self.lazy[idx] += inc
            return

        if self.lazy[idx] != 0:
            self.push_down(idx)

        self.update(idx * 2, low, high, inc)
        self.update(idx * 2 + 1, low, high, inc)
        self.min[idx] = min(self.min[idx * 2], self.min[idx * 2 + 1])
    
    def query(self, idx: int, low: int, high: int) -> int:
        if self.low[idx] > high or self.high[idx] < low:
            return 0x3f3f3f3f
        if low <= self.low[idx] and self.high[idx] <= high:
            return self.min[idx]
        if self.lazy[idx] != 0:
            self.push_down(idx)
        return min(self.query(idx * 2, low, high), self.query(idx * 2 + 1, low, high))
        

def read_input():
    n = int(readline().strip())
    data.extend([int(w) for w in readline().split()])
    m = int(readline().strip())
    for _ in range(m):
        ops.append(tuple(int(w) for w in readline().split()))

def solve()->list:
    sgt = SegTree(data)
    # sgt.dump()
    result = []
    for op in ops:
        if len(op) == 2:
            l, r = op
            if l > r:
                result.append(min(sgt.query(1, 0, r), sgt.query(1, l, len(data) -1)))
            else:
                result.append(sgt.query(1, l, r))
        else:
            l, r, inc = op
            if l > r:
                sgt.update(1, 0, r, inc)
                sgt.update(1, l, len(data) -1, inc)
            else:
                sgt.update(1, l, r, inc)
            # sgt.dump()
    return result


def write_output(result: list):
    for n in result:
        print(n)


read_input()
write_output(solve())
