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.
#include <iostream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstdio>

using namespace std;

const long long int INF = 1e17;

class SegmentTree
{
public:
    SegmentTree(vector<long long int> &datas, int left, int right):
        m_offset(0LL), m_min(0LL), m_left(left), m_right(right)
    {
        if(left == right-1)
            m_min = datas[left];
        else
        {
            int middle = (left + right) / 2;
            m_sonL = new SegmentTree(datas, left, middle);
            m_sonR = new SegmentTree(datas, middle, right);
            m_min = min(m_sonL->mini(left, middle), m_sonR->mini(middle, right));
        }
    }

    long long int mini(int left, int right)
    {
        if(left >= right) // CAS ERREUR
            return INF;
        if(left >= m_right || right <= m_left)
            return INF;
        if(left <= m_left && right >= m_right) //C'est le dernier � �tre touch�
            return m_min + m_offset;
        return m_offset + min(m_sonL->mini(left, right), m_sonR->mini(left, right)); //On passe aux fils
    }

    long long add(int left, int right, int offset) //On fait remonter le minimum pour mettre � jour en m�me temps
    {
        if(left >= right-1)
            return m_offset+m_min;
        if(left >= m_right || right <= m_left)
            return m_offset+m_min;
        if(left <= m_left && right >= m_right){//C'est le dernier � �tre touch�
            m_offset += offset;
            return m_min + m_offset;
        }
        m_min = min(m_sonL->add(left, right, offset), m_sonR->add(left, right, offset));//On passe aux fils
        return m_offset + m_min;
    }

private:
    long long int m_offset, m_min;
    int m_left, m_right; //[|m_right, m_left[|
    SegmentTree *m_sonR, *m_sonL;
};

class isChar
{
public:
    isChar(char c):
        m_c(c)
    {}
    bool operator()(char c)
    {
        return m_c == c;
    }
    char m_c;
};
int main()
{
    //On pr�traite les donn�es
    int n, ai, m;
    cin >> n;
    vector<long long int> datas(n);
    for(int i=0; i<n; i++){
        cin >> ai;
        cout << ai;
        datas[i] = ai;
    }
    SegmentTree arbre(datas, 0, n);

    //Puis on effectue les op�rations
    cin >> m;
    cin.ignore();
    int l, r, offset;
    string s;
    for(int i=0; i<m; i++){
        getline(cin, s);
        istringstream iss(s);
        if(count_if(s.begin(), s.end(), isChar(' ')) == 1){
            iss >> l >> r;
            if(l<=r)
                cout << arbre.mini(l, r+1) << endl;
            else{
                cout << min(arbre.mini(0, r+1), arbre.mini(l, n)) << endl;
            }
        }
        else{
            iss >> l >> r >> offset;
            if(l<=r)
                arbre.add(l, r+1, offset);
            else{
                arbre.add(0, n, offset);
                arbre.add(l+1,r, -offset);
            }
        }
    }

    return 0;
}

