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 typing import List

class Node ():
  def __init__ (self):
    self.min=float('inf')
    self.increase=0;
    self.left=self.right=None 
    self.lChild=self.rChild=None

def recalc(root:Node):
  if root.left==root.right :return 
  root.min=min(root.lChild.min+root.lChild.increase,root.rChild.min+root.rChild.increase)

def createSgTree(nums:List[int],l:int,r:int):
  root=Node()
  root.right=r 
  root.left=l
  if l==r : 
    root.min=nums[l]
  else :
    mid=(l+r)//2 
    root.lChild=createSgTree(nums,l,mid)
    root.rChild=createSgTree(nums,mid+1,r)
    recalc(root)
  return root

def propagation(root:Node) :
  root.min+=root.increase
  if root.left!=root.right :
    root.lChild.increase=root.rChild.increase=root.increase 
  root.increase=0

def updateRange(root:Node,ql:int,qr:int,diff):
  if ql<=root.left and root.right<=qr :
    root.increase+=diff 
    return 
  if root.left>qr or root.right<ql : return 
  if root.increase!=0 :propagation(root) 
  updateRange(root.lChild,ql,qr,diff)
  updateRange(root.rChild,ql,qr,diff)
  recalc(root)

def rangeMin(root:Node,ql,qr) :
  if ql<=root.left and root.right<=qr :return root.min +root.increase
  if root.left>qr or root.right<ql : return float('inf')
  if root.increase!=0 :
    propagation(root)
  return min(rangeMin(root.lChild,ql,qr),rangeMin(root.rChild,ql,qr))

class Solution():
  def Circular_RMQ(self,n:int,nums:List[int]):
    root=createSgTree(nums,0,n-1)
    nq=int(input())
    for i in range(nq):
      request=list(map(int, input().split()))
      if len(request)==2 :
        print(min(rangeMin(root,request[0],n-1),rangeMin(root,0,request[1])))
      else :
        updateRange(root,request[0],n-1,request[2])
        updateRange(root,0,request[1],request[2])

n=int(input())
nums = list(map(int, input().split()))
x=Solution()
x.Circular_RMQ(n,nums)
