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")
fast_print = lambda p: sys.stdout.write(str(p) + "\n") 

from math import inf

def make_lazy_segment_tree(arr):
  N = len(arr)
  size = 1 << (N-1).bit_length()
  tree = [inf] * (2*size)
  lazy = [0] * (2*size)
  for k in range(N):
    tree[size+k] = arr[k]
  for k in range(size-1,-1,-1):
    tree[k] = min(tree[2*k], tree[2*k+1])
  return tree, lazy

def push(tree, lazy, v):
  tree[2 * v] += lazy[v]
  lazy[2*v] += lazy[v]
  tree[2 * v + 1] += lazy[v]
  lazy[2*v+1] += lazy[v]
  lazy[v] = 0

def build(tree, lazy, v):
  v >>= 1
  while v:
    tree[v] = min(tree[2*v], tree[2*v+1]) + lazy[v]
    v >>= 1

def range_query(tree, lazy, l, r):
  res = inf
  l += len(tree) >> 1
  r += (len(tree) >> 1) + 1
  for k in range(l.bit_length()-1, 0, -1):
    push(tree, lazy, l >> k)
  for k in range((r-1).bit_length()-1,0,-1):
    push(tree, lazy, (r-1) >> k)
  while l < r:
    if l & 1:
      res = min(res, tree[l])
      l += 1
    if r & 1:
      r -= 1
      res = min(res, tree[r])
    l >>= 1
    r >>= 1
  return res

def range_update(tree, lazy, l, r, val):
  l += len(tree) >> 1
  r += (len(tree) >> 1) + 1
  old_l, old_r = l, r
  while l < r:
    if l & 1:
      tree[l] += val
      lazy[l] += val
      l += 1
    if r & 1:
      r -= 1
      tree[r] += val
      lazy[r] += val
    l >>= 1
    r >>= 1
  build(tree, lazy, old_l)
  build(tree, lazy, old_r-1)

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

tree, lazy = make_lazy_segment_tree(a)

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

def circular_range_query(l, r):
  if l <= r:
    return range_query(tree, lazy, l, r)
  else:
    return min(
      range_query(tree, lazy, l, n-1),
      range_query(tree, lazy, 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:
    fast_print(circular_range_query(op_args[0], op_args[1]))