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 = sys.stdin.readline

def lchild(idx): return 2*idx
def rchild(idx): return 2*idx+1

inf = 100000000
n = int(input())
a = list(map(int, input().split()))

tree = [0]*(4*n)
lazy = [0]*(4*n)

def build(arr, node, tl, tr):
  if tl == tr:
    tree[node] = arr[tl]
    return
  tm = (tl+tr) >> 1
  l_child = lchild(node)
  r_child = rchild(node)

  build(arr, l_child, tl, tm)
  build(arr, r_child, tm+1, tr)
  tree[node] = min(tree[l_child], tree[r_child])

#build the tree
build(a, 1, 0, n-1)

def push(node):
  l_child = lchild(node)
  r_child = rchild(node)
  tree[l_child] += lazy[node]
  tree[r_child] += lazy[node]

  lazy[l_child] += lazy[node]
  lazy[r_child] += lazy[node]

  lazy[node] = 0


def update(node, tl, tr, left, right, addend):
  if left > right:
    return
  if tl == left and tr == right:
    tree[node] += addend
    lazy[node] += addend
  else:
    push(node)
    tm = (tl+tr)>>1
    l_child = lchild(node)
    r_child = rchild(node)
    update(l_child, tl, tm, left, min(right, tm), addend)
    update(r_child, tm+1, tr, max(left, tm+1), right, addend)
    tree[node] = min(tree[l_child], tree[r_child])


def query(node, tl, tr, left, right):
  if left > right:
    return inf
  if left <= tl and tr <= right:
    return tree[node]
  else:
    push(node)
    l_child = lchild(node)
    r_child = rchild(node)
    tm = (tl+tr)>>1
    return min(query(l_child, tl, tm, left, min(right, tm)),
      query(r_child, tm+1, tr, max(left, tm+1), right))


m = int(input())
for _ in range(m):
  li = list(map(int, input().split()))
  if len(li) == 3:
    #update case
    start, end, value = li[0], li[1], li[2]
    if start <= end:
      update(1, 0, n-1, l, r, value)
    else:
      # have to do 2 updates from start to last elem and from first elem to end
      update(1, 0, n-1, start, n-1, value)
      update(1, 0, n-1, 0, end, value)
  else:
    start, end = li[0], li[1]
    if start <= end:
      print(query(1, 0, n-1, start, end))
    else:
      print(min(query(1, 0, n-1, start, n-1), query(1, 0, n-1, 0, end)))
