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 sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

from math import inf

def make_segment_tree(arr):
  N = len(arr)
  tree = [inf] * (4*N) # use-case
  lazy = [0] * (4*N)
  build(tree, arr, 1, 0, N-1)
  return tree, lazy

def build(tree, arr, vertex, tree_left, tree_right):
  if tree_left == tree_right:
    tree[vertex] = arr[tree_left]
  else:
    tree_middle = (tree_left + tree_right) // 2
    build(tree, arr, vertex*2, tree_left, tree_middle)
    build(tree, arr, vertex*2+1, tree_middle+1, tree_right)
    tree[vertex] = min(tree[vertex*2], tree[vertex*2+1])

def push(tree, lazy, vertex):
  tree[2 * vertex] += lazy[vertex]
  lazy[2*vertex] += lazy[vertex]

  tree[2 * vertex + 1] += lazy[vertex]
  lazy[2*vertex+1] += lazy[vertex]
  
  lazy[vertex] = 0

def range_update(tree, lazy, v, tl, tr, l, r, value):
  # print(f"RU called with v = {v}, tl = {tl}, tr = {tr}, l = {l}, r = {r}, value = {value}")
  if l > r:
    # print(f"  l > r: returning")
    return
  if tl == l and tr == r:
    # print(f"  exact hit: adjusting tree and lazy")
    tree[v] += value
    lazy[v] += value
  else:
    # print(f"  adjusting: pushing and subdividing")
    push(tree, lazy, v)
    tm = (tl + tr) // 2
    range_update(tree, lazy, v*2, tl, tm, l, min(r, tm), value)
    range_update(tree, lazy, v*2+1, tm+1, tr, max(l, tm+1), r, value)
    tree[v] = min(tree[v*2], tree[v*2+1])

def range_query(tree, lazy, vertex, tree_left, tree_right, arr_left, arr_right):
  if arr_left > arr_right:
    return inf
  if arr_left == tree_left and tree_right == arr_right:
    return tree[vertex]
  push(tree, lazy, vertex)
  tree_middle = (tree_left + tree_right) // 2
  return min(
    range_query(tree, lazy, vertex*2, tree_left, tree_middle, arr_left, min(tree_middle, arr_right)),
    range_query(tree, lazy, vertex*2+1, tree_middle+1, tree_right, max(arr_left, tree_middle+1), arr_right)
  )


n = int(input())
a = list(map(int,sys.stdin.readline().split()))
m = int(input())

# print(f"n = {n}, a = {a}, m = {m}")

tree, lazy = make_segment_tree(a)

def circular_range_update(l,r,v):
  # print(f"CRU called with l = {l}, r = {r}, v = {v}")
  if l <= r:
    range_update(tree, lazy, 1, 0, n-1, l, r, v)
  else:
    # print(f"circular query: calling {(l, n-1)} and {(0, r)}")
    range_update(tree, lazy, 1, 0, n-1, l, n-1, v)
    range_update(tree, lazy, 1, 0, n-1, 0, r, v)

def circular_range_query(l, r):
  if l <= r:
    return range_query(tree, lazy, 1, 0, n-1, l, r)
  else:
    return min(
      range_query(tree, lazy, 1, 0, n-1, l, n-1),
      range_query(tree, lazy, 1, 0, n-1, 0, r),
    )

for _ in range(m):
  op_args = list(map(int,sys.stdin.readline().split()))
  if len(op_args) == 3:
    circular_range_update(op_args[0], op_args[1], op_args[2])
    # print(f"result tree = {tree}")
    # print(f"result lazy = {lazy}")
  else:
    print(circular_range_query(op_args[0], op_args[1]))