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

def construct_segment_tree(segtree, a, n):  
      
    # assign values to leaves of  
    # the segment tree  
    for i in range(n):  
        segtree[n + i] = a[i];  
      
    # assign values to remaining nodes  
    # to compute minimum in a given range  
    for i in range(n - 1, 0, -1):  
        segtree[i] = min(segtree[2 * i],  
                         segtree[2 * i + 1])  
                          
def range_query(segtree, left, right, n): 
    left += n  
    right += n 
      
    """ Basically the left and right indices  
        will move towards right and left respectively  
        and with every each next higher level and  
        compute the minimum at each height change  
        the index to leaf node first """
    mi = 1e9 # initialize minimum to a very high value 
    while (left < right): 
        if (left & 1): # if left index in odd  
                mi = min(mi, segtree[left]) 
                left = left + 1
        if (right & 1): # if right index in odd  
                right -= 1
                mi = min(mi, segtree[right]) 
                  
        # move to the next higher level 
        left = left // 2
        right = right // 2
    return mi 
  
def update(segtree, pos, value, n): 
      
    # change the index to leaf node first  
    pos += n  
      
    # update the value at the leaf node  
    # at the exact index 
    segtree[pos] = value  
    while (pos > 1): 
          
        # move up one level at a time in the tree  
        pos >>= 1;  
          
        # update the values in the nodes  
        # in the next higher level 
        segtree[pos] = min(segtree[2 * pos],  
                           segtree[2 * pos + 1])  

def increase(segtree, pos, value, n): 
      
    # change the index to leaf node first  
    pos += n  
      
    # update the value at the leaf node  
    # at the exact index 
    segtree[pos] += value  
    while (pos > 1): 
          
        # move up one level at a time in the tree  
        pos >>= 1;  
          
        # update the values in the nodes  
        # in the next higher level 
        segtree[pos] = min(segtree[2 * pos],  
                           segtree[2 * pos + 1])  

lines = sys.stdin.read().split("\n")
lines.pop(-1)


n = int(lines.pop(0))
a = [int(x) for x in lines.pop(0).split(" ")]
ops = int(lines.pop(0))
  
# Construct the segment tree by assigning 
# the values to the internal nodes 
segtree = [0 for i in range(2 * n)]  
construct_segment_tree(segtree, a, n);

for line in lines:
    #print("==========")
    values = line.split(" ")
    if len(values) == 2:
        a,b = values
        a=int(a)
        b=int(b)

        if a <b:
            print(range_query(segtree,a,b+1,n))

        else:
            if abs(a-b) >= n-1:
                print(range_query(segtree, 0, n, n))
            else:
                print(min(range_query(segtree, b%n,n, n), range_query(segtree, 0,a+1, n) )                )

    else:
        a,b,v = values
        a=int(a)
        b=int(b)
        v=int(v)

        #print("Rango:")
        #print("A es "+str(a))
        #print("B es "+str(b))
        
        if a<b:
            for i in range(a,b+1):
                increase(segtree, i%n, v, n);
        else:
            for i in range(a,n):
                increase(segtree, i, v, n);
            for i in range(0,b+1):
                increase(segtree, i, v, n);
        



