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 log2, ceil

inf = 10e7

n = int(input())
numbers = [int(i) for i in input().strip().split()]
numbers.insert(0, 0)
#print(numbers)

rmq = [[inf for j in range(n+1)] for i in range(ceil(log2(n)) + 1)]

for i in range(1, len(numbers)):
    rmq[0][i] = numbers[i]

def update_rmq():
    global rmq
    rmq = [[inf for j in range(n+1)] for i in range(ceil(log2(n)) + 1)]

    for i in range(1, len(numbers)):
        rmq[0][i] = numbers[i]

    for i in range(1 ,ceil(log2(n)+1)):
        for j in range(1, n+1):
            rmq[i][j] = rmq[i-1][j]
            if j + (2 ** (i-1)) <= n:
                rmq[i][j] = min(rmq[i-1][j], rmq[i-1][j + (2 ** (i-1))])

update_rmq()

def query(l, r):
    #print(f"query({l}, {r}) çağırıldı...")
    #print("Güncel RMQ:", *rmq, sep="\n")
    l += 1
    r += 1
    t = r-l+1

    if t>1:
        x = int(log2(t))
        ans = inf
        for j in range(x, -1, -1):
            if 2**j <= t:
                ans = min(ans, rmq[j][l])
                l += 2**j
                t -= 2**j
        #print(f"normal rmq işlemleri yapıldı sonuç = {ans}...")
        return ans
    elif t==1:
        #print(f"{l} ve {r} aynı sonuç = {numbers[l]}...")
        return numbers[l]
    else:
        l -= 1
        r -= 1
        #print(f"dairesel rmq işlemleri yapıldı sonuç = min( query({l}, {n-1}), query({0}, {r}) )...")
        return min(query(l, n-1), query(0, r))


def update_numbers(l, r, x):
    #print(f"update_number({l}, {r}, {x}) çalıştırıldı.")
    if r-l >= 0:
        for index in range(l+1, r+2):
            numbers[index] += x
    else:
        for index in range(l+1, n+1):
            numbers[index] += x
        for index in range(1, r+2):
            numbers[index] += x

    #print(f"Yeni numbers = {numbers}")
    update_rmq()

#print(*rmq, sep="\n")

output = []

m = int(input())
for i in range(m):
    inp = [int(i) for i in input().strip().split()]

    # rmq query
    if len(inp) == 2:
        l, r = inp
        output.append(query(l, r))

    # list increasing & rmq updating
    elif len(inp) == 3:
        l, r, x = inp
        update_numbers(l, r, x)

print(*output, sep="\n")

  				 	 		 		  		 		 	  		 		