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 sys import stdin, stdout
from math import inf


class segmentTree:

    def __init__(self, arr, n):
        self.size = 1
        while self.size < n:
            self.size *= 2
        self.values = [inf] * (2 * self.size - 1)
        self.operation = [1e9] * (2 * self.size - 1)
        self.NO_OPERATION = 1e9
        self.build(arr, 0, self.size, 0)

    def build(self, arr, left, right, i):
        if right - left == 1:
            if left < len(arr):
                self.values[i] = arr[left]
            return
        m = (left+right)// 2
        self.build(arr, left, m, 2*i+1)
        self.build(arr, m, right, 2*i+2)
        self.values[i] = min(self.values[2*i+1], self.values[2*i+2])


    def propagation(self, left, right, i):
        if right - left == 1:
            return

        if self.operation[i] != self.NO_OPERATION:
            self.operation[2*i+1] = self.operation[i]
            self.operation[2*i+2] = self.operation[i]
            self.values[2*i+1] += self.operation[i]
            self.values[2*i+2] += self.operation[i]
            self.operation[i] = self.NO_OPERATION


    def update(self, a, b, left, right, i, x):
        self.propagation(left, right, i)
        if a >= right or b <= left:
            return

        if a <= left and b >= right:

            self.values[i] += x
            if self.operation[i] == self.NO_OPERATION:
                self.operation[i] = x
            else:
                self.operation[i] += x
            return

        mid = (left + right) //2
        self.update(a, b, left, mid, 2*i+1, x)
        self.update(a, b, mid, right, 2*i+2, x)
        self.values[i] = min(self.values[2*i+1], self.values[2*i+2])


    def query(self, a, b, left, right, i):
        self.propagation(left, right, i)
        if a >= right or b <= left:
            return inf

        if a <= left and b >= right:
            return self.values[i]

        mid = (left + right) // 2
        left_side = self.query(a, b, left, mid, 2 * i + 1)
        right_side = self.query(a, b, mid, right, 2 * i + 2)
        # self.values[i] = min(self.values[2 * i + 1], self.values[2 * i + 2])
        return min(left_side, right_side)


if __name__ == '__main__':
    input = stdin.readline
    n = int(input())
    arr = [int(x) for x in input().split()]
    tree = segmentTree(arr, n)
    m = int(input())
    for _ in range(m):
        op = [int(x) for x in input().split()]
        if len(op) == 2:
            if op[0] <= op[1]:
                x = tree.query(op[0], op[1]+1, 0, tree.size, 0)
                # print(x)
                stdout.write(f'{x}\n')
            else:
                x = tree.query(op[0], tree.size, 0, tree.size, 0)
                y = tree.query(0, op[1]+1, 0, tree.size, 0)
                # print(min(x, y))
                stdout.write(f'{min(x, y)}\n')
        else:
            if op[0] <= op[1]:
                tree.update(op[0], op[1], 0, tree.size, 0, op[2])
            else:
                tree.update(op[0], tree.size, 0, tree.size, 0, op[2])
                tree.update(0, op[1]+1, 0, tree.size, 0, op[2])