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.
# http://codeforces.com/problemset/problem/52/C
import bisect  # bisect.bisect(list, value)
import collections
import re
import sys
import threading


class Node:
    # my under range is [l, r]
    l = 0
    r = 0
    mini = 0
    incre = 0


N = [Node() for _ in range(1000000)]
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().strip().split()))
m = int(sys.stdin.readline())

A.insert(0, 0)  # for makes start index to  1


def build(k, L, R):
    N[k].l = L
    N[k].r = R
    N[k].incre = 0

    if L == R:  # leaf
        N[k].mini = A[L]
    else:
        mid = (L + R) // 2

        build(k * 2, L, mid)
        build(k * 2 + 1, mid + 1, R)

        N[k].mini = min(N[k * 2].mini + N[k * 2].incre, N[k * 2 + 1].mini + N[k * 2 + 1].incre)


def query(k, L, R):
    if N[k].l >= L and N[k].r <= R:  #
        return N[k].mini + N[k].incre
    elif N[k].l > R or N[k].r < L:
        return 999999999999999
    else:
        mid = (N[k].l + N[k].r) // 2

        lret = query(k * 2, L, R)
        rret = query(k * 2 + 1, L, R)

        return min(lret, rret) + N[k].incre


def increasement(k, L, R, V):
    if N[k].l >= L and N[k].r <= R:  #
        N[k].incre += V
    elif N[k].l > R or N[k].r < L:
        return  # do nothing
    else:
        mid = (N[k].l + N[k].r) // 2

        increasement(k * 2, L, R, V)
        increasement(k * 2 + 1, L, R, V)

        N[k].mini = min(N[k * 2].mini + N[k * 2].incre, N[k * 2 + 1].mini + N[k * 2 + 1].incre)


for _ in range(m):
    opr = list(map(int, sys.stdin.readline().strip().split()))

    build(1, 1, n)

    if len(opr) == 2:  # rmq(lf, rg) — this operation returns minimal value on the segment [lf, rg] (inclusively).
        if L <= R:
            print(query(1, opr[0] + 1, opr[1] + 1))
        else:
            lret = query(1, 1, opr[1] + 1)
            rret = query(1, opr[0] + 1, n)
            print(min(lret, rret))
    elif len(opr) == 3:  # inc(lf, rg, v) — this operation increases each element on the segment [lf, rg] (inclusively) by v;
        if L <= R:
            increasement(1, opr[0] + 1, opr[1] + 1, opr[2])
        else:
            increasement(1, 1, opr[1] + 1, opr[2])
            increasement(1, opr[0] + 1, n, opr[2])