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>
using namespace std;

const int N = (1e5 * 2) + 5;
int a[N];
int n, q;
char c;
long long tree[4 * N], lazy[4 * N];
bool upd[4 * N];

void build(int id = 0, int ns = 0, int ne = n - 1) {
    if (ns == ne) {
        tree[id] = a[ns];
        return;
    }
    int left = 2 * id + 1;
    int right = left + 1;
    int md = ns + (ne - ns) / 2;
    build(left, ns, md);
    build(right, md + 1, ne);
    tree[id] = min(tree[left], tree[right]);
}

void unlazy(int id, int ns, int ne) {
    if (!upd[id]) {
        return;
    }
    tree[id] += lazy[id] * (ne - ns + 1);
    if (ns != ne) {
        int l = id * 2 + 1;
        int r = l + 1;
        lazy[l] += lazy[id];
        lazy[r] += lazy[id];
    }
    upd[id] = 0;
    lazy[id] = 0;
}

void update(int qs, int qe, int v, int id = 0, int ns = 0, int ne = n - 1) {
    unlazy(id, ns, ne);
    if (ns > qe || ne < qs) {
        return;
    }
    if (qs <= ns && qe >= ne) {
        lazy[id] += v;
        upd[id] = 1;
        unlazy(id, ns, ne);
        return;
    }
    int left = 2 * id + 1;
    int right = left + 1;
    int md = (ne + ns) / 2;
    update(qs, qe, v, left, ns, md);
    update(qs, qe, v, right, md + 1, ne);
    tree[id] = min(tree[left], tree[right]);
}

long long query(int qs, int qe, int id = 0, int ns = 0, int ne = n - 1) {
    unlazy(id, ns, ne);
    if (ns > qe || qs > ne) {
        return 1e7;
    }
    if (qs <= ns && qe >= ne) {
        return tree[id];
    }
    int left = 2 * id + 1;
    int right = left + 1;
    int md = ns + (ne - ns) / 2;
    return min(query(qs, qe, left, ns, md), query(qs, qe, right, md + 1, ne));
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cin >> q;
    build(0, 0, n - 1);
    while (q--) {
        vector<int> op;
        int val;
        while (cin >> val) {
            op.push_back(val);
            if (cin.get() == '\n') {
                break;
            }
        }
        if (op.size() == 2) {
            if (op[0] > op[1]) {
                cout << min(query(op[0], n - 1), query(0, op[1])) << endl;
            }
            else {
                cout << query(op[0], op[1]) << endl;
            }
        }
        if (op.size() == 3) {
            if (op[0] > op[1]) {
                update(op[0], n - 1, op[2]);
                update(0, op[1], op[2]);
            }
            else {
                update(op[0], op[1], op[2]);
            }
        }
    }
    return 0;
}