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 *
import itertools

cin = list(stdin)

def wr(text):
    stdout.write(str(text))

def war(a):
    stdout.write(' '.join(map(str, a)) + '\n')

def wrl(text):
    stdout.write(str(text) + '\n')

_i_ = 0
def inp():
    global _i_
    _i_ += 1
    return cin[_i_ - 1]

n = int(inp())
a = [int(i) for i in inp().split()]

t = [10**12] * 4 * n
lp = [0] * 4 * n

def build(v, tl, tr):
    if (tl == tr - 1):
        t[v] = a[tl]
        lp[v] = a[tl]
    else:
        tm = (tl + tr) // 2
        build(2*v + 1, tl, tm)
        build(2*v + 2, tm, tr)
        t[v] = min(t[2*v + 1], t[2*v + 2])

def update(v, tl, tr, l, r, x):
    if l >= r:
        return
    elif tl == l and tr == r:
        t[v] += x
        lp[v] += x
    else:
        tm = (tl + tr) // 2
        update(2*v + 1, tl, tm, l, min(r, tm), x)
        update(2*v + 2, tm, tr, max(l, tm), r, x)
        t[v] = min(t[2*v + 1], t[2*v + 2]) + lp[v]

def query(v, tl, tr, l, r):
    if l >= r:
        return 10**12
    elif tl == l and tr == r:
        return t[v]
    else:
        tm = (tl + tr) // 2
        return min(query(2*v + 1, tl, tm, l, min(r, tm)), query(2*v + 2, tm, tr, max(l, tm), r)) + lp[v]


build(0, 0, n)
q = int(inp())
for i in range(q):
    x = [int(i) for i in inp().split()]
    if len(x) == 2:
        if x[0] > x[1]:
            wrl(min(query(0, 0, n, x[0], n), query(0, 0, n, 0, x[1] + 1)))
        else:
            wrl(query(0, 0, n, x[0], x[1] + 1))
    else:
        if x[0] > x[1]:
            update(0, 0, n, x[0], n, x[2])
            update(0, 0, n, 0, x[1] + 1, x[2])
        else:
            update(0, 0, n, x[0], x[1] + 1, x[2])
