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.
from math import log2 ,ceil 
from typing import List 
def constructUtil(arr:List[int],segTree:List[int],ss,se,si):
  if ss==se :
    segTree[si]=arr[ss]
    return arr[ss]
  mid=(ss+se)//2
  segTree[si]=min(constructUtil(arr,segTree,ss,mid,2*si+1),constructUtil(arr,segTree,mid+1,se,2*si+2))
  return segTree[si]
def construct(arr:List[int],segTree:List[int],lazy:List[int]):
  constructUtil(arr,segTree,0,n-1,0)
  return segTree 
def updateRangeUtil(tree:List[int],lazy:List[int],ss,se,us,ue,si,diff): 
  if lazy[si]!=0 :
    tree[si]+=lazy[si]
    if ss!=se :
      lazy[2*si+1]+=lazy[si]
      lazy[2*si+1]+=lazy[si]
    lazy[si]=0
  if us>se or ue<ss or ss>se :
    return
  if ss>=us and se<=ue :
 
    tree[si]=tree[si]+diff
    if ss!=se :
      lazy[2*si+1]+=diff
      lazy[2*si+2]+=diff
    return 
  mid = (ss + se) // 2
  updateRangeUtil(tree,lazy,ss,mid,us,ue,2*si+1,diff)
  updateRangeUtil(tree,lazy,mid+1,se,us,ue,2*si+2,diff)
  tree[si] = min(tree[si * 2 + 1] , tree[si * 2 + 2])
def getMinUtil(tree:List[int],lazy:List[int],si,ss,se,qs,qe):
  if lazy[si]!=0 :
    tree[si]+=lazy[si]
    if ss!=se:
      lazy[2*si+1]+=lazy[si]
      lazy[2*si+1]+=lazy[si]
    lazy[si]=0
  if qs>se or qe<ss or ss> se:
    return 10000000
  if ss>=qs and se<=qe :
    return tree[si]
  mid=(ss+se)//2
  return min(getMinUtil(tree,lazy,2*si+1,ss,mid,qs,qe),getMinUtil(tree,lazy,2*si+2,mid+1,se,qs,qe))
def getMin(tree,lazy,qs,qe,n):
  return getMinUtil(tree,lazy,0,0,n-1,qs,qe)
def updateRange(tree,lazy,us,ue,diff,n):
  updateRangeUtil(tree,lazy,0,n-1,us,ue,0,diff)
class Solution():
  def Circular_RMQ(self,arr:List[int],arrOp:List[int]):
    n=len(arr)
    height = ceil(log2(n))
    tree=[0]*(2*(2**height)-1)
    lazy=[0]*(2*(2**height)-1)
    construct(arr,tree,lazy)
    for i in range(len(arrOp)):
      temp=arrOp[i]
      if len(temp)==2 :
        if temp[1]<temp[0]:
          print(min(getMin(tree,lazy,0,temp[1],n),getMin(tree,lazy,temp[0],n-1,n)))
        else :
          print(getMin(tree,lazy,temp[0],temp[1],n))
      else :
        if temp[1]<temp[0]:
          updateRange(tree,lazy,0,temp[1],temp[2],n)
          updateRange(tree,lazy,temp[0],n-1,temp[2],n)
        else :
          updateRange(tree,lazy,temp[0],temp[1],temp[2],n)
      
arr=[]
n=int(input())
arr = list(map(int,input().strip().split()))[:n]
nOp=int(input())
arrOp=list()
for x in range(nOp):
tmp=list(map(int,input().strip().split()))[:nOp]
arrOp.append(tmp)
x=Solution()
x.Circular_RMQ(arr,arrOp)