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 random
INF = 10**10

def Size(T):
    return T.sz if T else 0
def Min(T):
    return T.min if T else INF
class TreapNode():

    def __init__(self, value=INF):
        self.lc = None
        self.rc = None
        self.sz = 1
        self.pri = random.randint(1, INF)
        self.value = value
        self.min = value
        self.add_tag = 0

    def size(self, T):
        return T.sz if T else 0

    def Min(self, T):
        return T.min if T else INF

    def pull(self):
        self.min = min(self.value, self.Min(self.lc),self.Min(self.rc) )
        self.sz = 1 + self.size(self.lc) + self.size(self.rc)

    def push(self):
        if self.add_tag != 0:
            self.value += self.add_tag
            self.min += self.add_tag
            if self.lc:
                self.lc.add_tag += self.add_tag
            if self.rc:
                self.rc.add_tag += self.add_tag
            self.add_tag = 0

class Treap():

    def new_node(self, v):
        return TreapNode(v)

    def merge(self, a, b):
        if not a or not b:
            return a if not b else b

        if a.pri > b.pri:
            a.push()
            a.rc = self.merge(a.rc, b)
            a.pull()
            return a
        else:
            b.push()
            b.lc = self.merge(a, b.lc)
            b.pull()
            return b

    def split(self, t, k):
        if not t:
            return (None, None)
            return

        t.push()
        if k > Size(t.lc):
            a = t
            a.rc, b = self.split(t.rc, k-t.size(t.lc)-1)
            a.pull()
            return (a, b)
        else:
            b = t
            a, b.lc = self.split(t.lc, k)
            b.pull()
            return (a, b)

T = None
treap = Treap()

N = int(input())
ns = map(int, input().split())
for i in ns:
    tmp_t = treap.new_node(i)
    T = treap.merge(T, tmp_t)

Q = int(input())
for qs in range(Q):
    query = list(map(int, input().split()))

    l, r = query[0]+1, query[1]+1
    mi, mx = (min(l,r), max(l,r))
    T1, T2, T3 = 0, 0, 0
    if l <= r:
        T1, T2 = treap.split(T, mi-1)
        T2, T3 = treap.split(T2, mx-mi+1)
    else:
        T1, T2 = treap.split(T, mi)
        T2, T3 = treap.split(T2, mx-mi-1)
    #print("size", Size(T1), Size(T2), Size(T3))

    if len(query) == 3:
        v = query[2]
        if l < r:
            if T2 : T2.add_tag += v
        else:
            if T1 : T1.add_tag += v
            if T3 : T3.add_tag += v

    elif len(query) == 2:
        Min(T1)
        if l < r:
            print( Min(T2))
        else:
            print( min(Min(T1), Min(T3)) )
    
    T = treap.merge(T1, T2)
    T = treap.merge(T, T3)

