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.
class SegmentTree:
  lo = []
  hi = []
  mini = []
  delta = []
  n = 0
  
  def __init__(self,n,arr):
    self.lo = [0] * (4*n + 1)
    self.hi = [0] * (4*n + 1)
    self.mini = [10**6+1] * (4*n + 1)
    self.delta = [0] * (4*n + 1)
    self.n = n
    self.initialize(1,0,self.n-1,arr)  
  

  # initialize the lo and hi as dividing the array each time into half, storing the indices of the range
  def initialize(self,i,a,b,arr):
    
    self.lo[i] = a
    self.hi[i] = b
    if a==b:
      self.mini[i] = arr[a]
      return
    
    mid = a + (b - a)//2

    self.initialize(2*i, a, mid,arr)
    self.initialize(2*i+1, mid+1, b,arr)

    self.update(i)

  # propagating the change down to the left and right child of the current node  
  def prop(self,i):
    self.delta[2*i] = self.delta[i]
    self.delta[2*i+1] = self.delta[i]
    self.delta[i] = 0

  # updating the minimum as we move up the tree, from its left and right child, along with adding any delta
  def update(self,i):
    self.mini[i] = min(self.mini[2*i] + self.delta[2*i], self.mini[2*i+1] + self.delta[2*i+1])
 
  def increment(self,a,b,val):
    if a> b:
      self.increment_index(1,a,self.n,val)
      self.increment_index(1,0,b,val)
      return
    self.increment_index(1,a,b,val)

  def minimumn(self,a,b):
    if a > b:
      return min(self.minimum_value(1,a,self.n), self.minimum_value(1,0,b))
    return self.minimum_value(1,a,b)

  def minimum_value(self,i,a,b):
    if b < self.lo[i] or self.hi[i] < a:
      return 10**6+1

    if self.lo[i] >= a and self.hi[i] <= b:
      return self.mini[i] + self.delta[i]

    self.prop(i)

    left_min = self.minimum_value(2*i,a,b)
    right_min = self.minimum_value(2*i+1,a,b)

    self.update(i)

    return min(left_min,right_min)
  
  def increment_index(self,i,a,b,val):
    
    # if the range a to b is not in lo[i] to hi[i]
    if (b < self.lo[i] or self.hi[i] < a):
      return

    # if the range a to b lies completely in lo[i] to hi[i]
    if (self.lo[i]>=a and self.hi[i]<=b):
      self.delta[i] += val
      return

    self.prop(i)

    self.increment_index(2*i, a, b, val)
    self.increment_index(2*i+1, a, b ,val)

    self.update(i)
    

  def print(self):
    # print (self.n)
    print (self.lo)
    print (self.hi)
    print (self.mini)
    print (self.delta)


if __name__ == "__main__":
  n = int(input())
  arr = list(map(int,input().split()))
  segmentTree = SegmentTree(n,arr)

  for _ in range(int(input())):
    ran = list(map(int,input().split()))
    if len(ran) == 3:
      segmentTree.increment(ran[0],ran[1],ran[2])
    else:
      print(segmentTree.minimumn(ran[0],ran[1]))

    
    


'''
2
-1 -1
10
0 0
0 0
0 0 1
0 0
1 1
0 0 -1
0 0 0
0 0 1
1 1 0
0 0 -1


'''

'''
4
1 2 3 4
4
3 0
3 0 -1
0 1
2 1


'''