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 math

def preprocess_rmq(arr, n):
    block_size = int(math.sqrt(n)) + 1
    num_blocks = (n + block_size - 1) // block_size
    min_blocks = [float('inf')] * num_blocks
    
    for i in range(n):
        block_index = i // block_size
        min_blocks[block_index] = min(min_blocks[block_index], arr[i])
    
    return min_blocks

def query_rmq(arr, min_blocks, left, right):
    block_size = len(min_blocks)
    min_val = float('inf')
    
    #Min del bloque izq
    while left <= right and left % block_size != 0:
        min_val = min(min_val, arr[left])
        left += 1
    
    # Find minimum within full blocks
    while left + block_size <= right:
        block_index = left // block_size
        min_val = min(min_val, min_blocks[block_index])
        left += block_size
    
    # Find minimum within the right block
    while left <= right:
        min_val = min(min_val, arr[left])
        left += 1
    
    return min_val



# Lectura de la entrada
n = int(input())
arr = list(map(int, input().split()))
m = int(input())

min_blocks = preprocess_rmq(arr, n)
# Realizar preprocesamiento
st = preprocess_rmq(arr,n)

# Procesar las operaciones

for _ in range(m):
    operation = list(map(int, input().split()))
    if len(operation) == 2:
        lf, rg = operation
        if lf <= rg:
            print(query_rmq(arr, min_blocks, lf, rg))
        else:
            print(min(query_rmq(arr, min_blocks, lf, n-1), query_rmq(arr, min_blocks, 0, rg)))
    else:
        lf, rg, v = operation
        for i in range(lf, rg+1):
            arr[i] += v
        min_blocks = preprocess_rmq(arr, n)