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 math import log, ceil


def construir_arbol(arbol, datos, izquierda, derecha, pivote=1):
    if izquierda == derecha:
        arbol[pivote-1] = datos[derecha-1]
        return

    mitad = (izquierda + derecha) // 2
    pivote_izquierdo = 2*pivote
    pivote_derecho = 2*pivote + 1

    construir_arbol(arbol, datos, izquierda, mitad, pivote_izquierdo)
    construir_arbol(arbol, datos, mitad+1, derecha, pivote_derecho)

    arbol[pivote-1] = min(arbol[pivote_izquierdo-1], arbol[pivote_derecho-1])


def calcular_postergado(arbol, lazy, izquierda, derecha, pivote):
    if lazy[pivote-1] == 0:
        return
    
    arbol[pivote-1] += lazy[pivote-1]

    if izquierda != derecha:
        pivote_izquierdo = 2*pivote
        pivote_derecho = 2*pivote + 1
        lazy[pivote_izquierdo-1] = lazy[pivote-1]
        lazy[pivote_derecho-1] = lazy[pivote-1]
    
    lazy[pivote-1] = 0


def menor_en_rango(arbol, lazy, lf, rg, izquierda, derecha, pivote=1):
    if rg < izquierda-1 or derecha-1 < lf:
        return float("inf")

    calcular_postergado(arbol, lazy, izquierda, derecha, pivote)

    if lf <= izquierda-1 and derecha-1 <= rg:
        return arbol[pivote-1]
    
    mitad = (izquierda + derecha) // 2
    pivote_izquierdo = 2*pivote
    pivote_derecho = 2*pivote + 1

    val_izq = menor_en_rango(arbol, lazy, lf, rg, izquierda, mitad, pivote_izquierdo)
    val_der = menor_en_rango(arbol, lazy, lf, rg, mitad+1, derecha, pivote_derecho)
    return min(val_izq, val_der)


def sumar_al_rango(arbol, lazy, lf, rg, v, izquierda, derecha, pivote=1):

    if rg < izquierda-1 or derecha-1 < lf:
        return

    calcular_postergado(arbol, lazy, izquierda, derecha, pivote)

    if lf <= izquierda-1 and derecha-1 <= rg:
        lazy[pivote-1] = v
        calcular_postergado(arbol, lazy, izquierda, derecha, pivote)
        return

    mitad = (izquierda + derecha) // 2
    pivote_izquierdo = 2*pivote
    pivote_derecho = 2*pivote + 1

    sumar_al_rango(arbol, lazy, lf, rg, v, izquierda, mitad, pivote_izquierdo)
    sumar_al_rango(arbol, lazy, lf, rg, v, mitad+1, derecha, pivote_derecho)

    arbol[pivote-1] = min(arbol[pivote_izquierdo-1], arbol[pivote_derecho-1])


n = int(input())
lista_a = list(map(int, input().split()))

tamaño = 2**ceil(log(n+1, 2))
arbol = [None for i in range(tamaño)]
lazy = [0 for i in range(tamaño)]

construir_arbol(arbol, lista_a, 1, n)

m = int(input())

for i in range(m):
    operation = list(map(int, input().split()))
    if len(operation) == 2:
        lf, rg = operation
        if rg < lf:
            a = menor_en_rango(arbol, lazy, lf, n, 1, n)
            b = menor_en_rango(arbol, lazy, 0, rg, 1, n)
            print(min(a, b))
        else:
            print(menor_en_rango(arbol, lazy, lf, rg, 1, n))
    else:
        lf, rg, v = operation
        if rg < lf:
            sumar_al_rango(arbol, lazy, lf, n, v, 1, n)
            sumar_al_rango(arbol, lazy, 0, rg, v, 1, n)
        else:
            sumar_al_rango(arbol, lazy, lf, rg, v, 1, n)
