You are given circular array a0, a1, ..., an - 1. 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.

Input

The first line contains integer n (1 ≤ n ≤ 200000). The next line contains initial state of the array: a0, a1, ..., an - 1 ( - 106 ≤ ai ≤ 106), ai 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; - 106 ≤ v ≤ 106) — inc operation.

Output

For each rmq operation write result for it. Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cout (also you may use %I64d).

Examples

Input

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


Output

1
0
0
#include <bits/stdc++.h>
using namespace std;
long long segTree[4 * 200010];
long long lazy[4 * 200010];
long long a[200010];
long long mini(long long a, long long b) {
  if (a > b) {
    return b;
  } else
    return a;
}
void build_tree(long long rangeLeft, long long rangeRight, long long index) {
  lazy[index] = 0;
  if (rangeLeft == rangeRight) {
    segTree[index] = a[rangeLeft];
    return;
  }
  long long mid = (rangeLeft + rangeRight) / 2;
  build_tree(rangeLeft, mid, 2 * index);
  build_tree(mid + 1, rangeRight, 2 * index + 1);
  segTree[index] = mini(segTree[2 * index], segTree[2 * index + 1]);
}
void update_tree(long long updateLeft, long long updateRight,
                 long long newValue, long long rangeLeft, long long rangeRight,
                 long long index) {
  if (lazy[index] != 0) {
    segTree[index] += lazy[index];
    if (rangeLeft != rangeRight) {
      lazy[2 * index] += lazy[index];
      lazy[2 * index + 1] += lazy[index];
    }
    lazy[index] = 0;
  }
  if (updateRight < rangeLeft || rangeRight < updateLeft) return;
  if (updateLeft <= rangeLeft && rangeRight <= updateRight) {
    segTree[index] += newValue;
    if (rangeLeft != rangeRight) {
      lazy[2 * index] += newValue;
      lazy[2 * index + 1] += newValue;
    }
    return;
  }
  long long mid = (rangeLeft + rangeRight) / 2;
  update_tree(updateLeft, updateRight, newValue, rangeLeft, mid, 2 * index);
  update_tree(updateLeft, updateRight, newValue, mid + 1, rangeRight,
              2 * index + 1);
  segTree[index] = mini(segTree[2 * index], segTree[2 * index + 1]);
}
long long query_tree(long long queryLeft, long long queryRight,
                     long long rangeLeft, long long rangeRight,
                     long long index) {
  if (queryRight < rangeLeft || rangeRight < queryLeft)
    return 100000000000000000;
  if (lazy[index] != 0) {
    segTree[index] += lazy[index];
    if (rangeLeft != rangeRight) {
      lazy[2 * index] += lazy[index];
      lazy[2 * index + 1] += lazy[index];
    }
    lazy[index] = 0;
  }
  if (queryLeft <= rangeLeft && rangeRight <= queryRight) return segTree[index];
  long long mid = (rangeLeft + rangeRight) / 2;
  return mini(
      query_tree(queryLeft, queryRight, rangeLeft, mid, 2 * index),
      query_tree(queryLeft, queryRight, mid + 1, rangeRight, 2 * index + 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  build_tree(1, n, 1);
  string str;
  long long q;
  char nl;
  cin >> q;
  getline(cin, str);
  long long x, y, z;
  for (long long i = 0; i < q; i++) {
    getline(cin, str);
    istringstream iss(str);
    vector<long long> v;
    while (!iss.eof()) {
      iss >> x;
      v.push_back(x);
    }
    if (v.size() == 2) {
      x = v[0] + 1, y = v[1] + 1;
      if (x <= y) {
        cout << query_tree(x, y, 1, n, 1) << "\n";
      } else {
        cout << mini(query_tree(1, y, 1, n, 1), query_tree(x, n, 1, n, 1))
             << "\n";
      }
    } else {
      x = v[0] + 1, y = v[1] + 1, z = v[2];
      if (x <= y) {
        update_tree(x, y, z, 1, n, 1);
      } else {
        update_tree(1, y, z, 1, n, 1);
        update_tree(x, n, z, 1, n, 1);
      }
    }
  }
}
