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
from io import BytesIO, IOBase
import os

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

class SegTreeNode:
    def __init__(self):
        self.min = 0x3f3f3f3f
        self.low = 0x3f3f3f3f
        self.high = -0x3f3f3f3f
        self.lazy = 0


class SegTree:
    def __init__(self, data: list):
        n = len(data)
        m = 1
        while m < n:
            m += m
        self.data = [SegTreeNode() for _ in range(m * 2 + 1)]
        for i in range(n):
            self.data[m + i].low = i
            self.data[m + i].high = i
            self.data[m + i].min = data[i]
        for i in range(m + n - 1, 1, -1):
            j = i >> 1
            self.data[j].min = min(self.data[j].min, self.data[i].min)
            self.data[j].low = min(self.data[j].low, self.data[i].low)
            self.data[j].high = max(self.data[j].high, self.data[i].high)

    # def dump(self):
    #     return
    #     result = []
    #     for i in range(len(self.data)):
    #         result.append([i, self.data[i].min, self.data[i].low,
    #                       self.data[i].high, self.data[i].lazy])
    #     print(result)

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

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

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

        lchild = idx << 1
        rchild = lchild + 1
        self.update(lchild, low, high, inc)
        self.update(rchild, low, high, inc)
        self.data[idx].min = min(self.data[lchild].min, self.data[rchild].min)
    
    def query(self, idx: int, low: int, high: int) -> int:
        if self.data[idx].low > high or self.data[idx].high < low:
            return 0x3f3f3f3f
        if low <= self.data[idx].low and self.data[idx].high <= high:
            return self.data[idx].min
        if self.data[idx].lazy != 0:
            self.push_down(idx)
        return min(self.query(idx << 1, low, high), self.query(1 + (idx << 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)


BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
readline = sys.stdin.readline
read_input()
write_output(solve())