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

# Function to build the segment tree
def buildSegmentTree(tree, arr, node, start, end):
    if start == end:
        tree[node] = arr[start]
    else:
        mid = (start + end) // 2
        left = 2 * node + 1
        right = 2 * node + 2
        buildSegmentTree(tree, arr, left, start, mid)
        buildSegmentTree(tree, arr, right, mid + 1, end)
        tree[node] = min(tree[left], tree[right])

# Function to update the segment tree
def updateSegmentTree(tree, lazy, node, start, end, updateStart, updateEnd, value):
    if lazy[node] != 0:
        tree[node] += lazy[node]
        if start != end:
            lazy[2 * node + 1] += lazy[node]
            lazy[2 * node + 2] += lazy[node]
        lazy[node] = 0

    if start > end or start > updateEnd or end < updateStart:
        return

    if start >= updateStart and end <= updateEnd:
        tree[node] += value
        if start != end:
            lazy[2 * node + 1] += value
            lazy[2 * node + 2] += value
        return

    mid = (start + end) // 2
    left = 2 * node + 1
    right = 2 * node + 2
    updateSegmentTree(tree, lazy, left, start, mid, updateStart, updateEnd, value)
    updateSegmentTree(tree, lazy, right, mid + 1, end, updateStart, updateEnd, value)
    tree[node] = min(tree[left], tree[right])

# Function to query the segment tree
def querySegmentTree(tree, lazy, node, start, end, queryStart, queryEnd):
    if lazy[node] != 0:
        tree[node] += lazy[node]
        if start != end:
            lazy[2 * node + 1] += lazy[node]
            lazy[2 * node + 2] += lazy[node]
        lazy[node] = 0

    if start > end or start > queryEnd or end < queryStart:
        return sys.maxsize

    if start >= queryStart and end <= queryEnd:
        return tree[node]

    mid = (start + end) // 2
    left = 2 * node + 1
    right = 2 * node + 2
    leftMin = querySegmentTree(tree, lazy, left, start, mid, queryStart, queryEnd)
    rightMin = querySegmentTree(tree, lazy, right, mid + 1, end, queryStart, queryEnd)
    return min(leftMin, rightMin)

# Main function to process the given sequence of operations
def processOperations(n, arr, m, operations):
    tree = [0] * (4 * n)
    lazy = [0] * (4 * n)

    # Build the segment tree
    buildSegmentTree(tree, arr, 0, 0, n - 1)

    # Process the operations
    results = []
    for op in operations:
        if len(op) == 2:  # RMQ operation
            lf, rg = op
            if lf <= rg:
                results.append(querySegmentTree(tree, lazy, 0, 0, n - 1, lf, rg))
            else:
                results.append(min(querySegmentTree(tree, lazy, 0, 0, n - 1, lf, n - 1),
                                   querySegmentTree(tree, lazy, 0, 0, n - 1, 0, rg)))
        else:  # INC operation
            lf, rg, v = op
            if lf <= rg:
                updateSegmentTree(tree, lazy, 0, 0, n - 1, lf, rg, v)
            else:
                updateSegmentTree(tree, lazy, 0, 0, n - 1, lf, n - 1, v)
                updateSegmentTree(tree, lazy, 0, 0, n - 1, 0, rg, v)

    return results

# Read the input
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
operations = []
for _ in range(m):
    line = input().split()
    if line[0] == 'rmq':
        operations.append((int(line[1]), int(line[2])))
    else:
        operations.append((int(line[1]), int(line[2]), int(line[3])))

# Process the operations and print the results
results = processOperations(n, arr, m, operations)
for res in results:
    print(res)
