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.
#On récupère les data

n = int(input());

#todo: sauvegarde du minimum
#La classe qui sert à modifier les données
class DonneesPartielles:
    def __init__(self, t, calque, chemin = 0):
        self.datas = t;
        self.add = 0;
        self.fils = []
        self.last = calque == 0;
        self.calqueD = calque * 2 - 1
        self.calqueG = (len(t)-1) ^ (self.calqueD // 2)
        self.calque = calque

        ##print(calque)

        if(not(self.last)):
            self.fils = [DonneesPartielles(t, calque // 2, chemin * 2), DonneesPartielles(t, calque // 2, chemin * 2 + 1)]
            self.min = min(self.fils[0].min, self.fils[1].min)
        else:
            self.min = t[chemin];

        ##print(self.calque, self.calqueD, self.calqueG)

    def add_nb(self, toAdd, left, right):
        ##print(left, '-', right, '; ', self.calque)
        if self.last:
            ##print(" ", 1)
            self.datas[left] += toAdd;
            self.min += toAdd;
            return;
        if not(left&self.calqueD) and not((right+1)&self.calqueD):
            ##print(" ", 2)
            self.add += toAdd;
            self.min += toAdd;
            return;
        if (left & self.calque) == (right & self.calque):
            ##print(" ", 3)
            self.fils[left&self.calque !=0].add_nb(toAdd, left, right)
            self.min = min(self.fils[0].min, self.fils[1].min) + self.add;
            return;
        ##print(" ", 4)
        limiteGauche = (left&self.calqueG) + (self.calqueD // 2)
        self.fils[0].add_nb(toAdd, left, limiteGauche)
        self.fils[1].add_nb(toAdd, limiteGauche+1, right)
        self.min = min(self.fils[0].min, self.fils[1].min) + self.add;
        
    def get_data(self, i):
        if self.last:
            return self.datas[i];
        return self.add + self.fils[i&self.calque !=0].get_data(i)

    def get_min(self, left, right):
        if self.last:
            return self.datas[left];
        if not(left&self.calqueD) and not((right+1)&self.calqueD):
            return self.add + self.min;
        if (left & self.calque) == (right & self.calque):
            return self.fils[left&self.calque !=0].get_min(left, right) + self.add;
        limiteGauche = (left&self.calqueG) + (self.calqueD // 2)
        return min(self.fils[0].get_min(left, limiteGauche),
                self.fils[1].get_min(limiteGauche+1, right)) + self.add;
        
        
        
            

def convert(n, k):
    res = [0] * k
    i = k-1
    while n:
        res[i] = n % 2
        n //= 2
        i -= 1
    return res;

#On détermine la puissance de 2 au dessus de n
m = 1;
n_b = n
while n_b:
    n_b //= 2
    if m != n:
        m *= 2;
datas = [int(ai) for ai in input().split()]
datas += [0] * (m-n)

arbre = DonneesPartielles(datas, m //2)
        

##print(datas)


k = int(input());
for _ in range(k):
    cmd = [int(s) for s in input().split()];
    if len(cmd) == 3:
        l, r, add = cmd;
        if l > r:
            l, r = r+1, l-1
            arbre.add += add
            add = -add
        arbre.add_nb(add, l, r);
    else:
        l, r = cmd;
        if l > r:
            print(min(arbre.get_min(0, r), arbre.get_min(l, n-1)));
        else:
            print(arbre.get_min(l, r));












    
