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;
constexpr long long int MAX = 1000000000000;
constexpr long long int MAXL = 200001;
vector<long long int> tree(MAXL * 4);
vector<long long int> lazy(MAXL * 4);
void LazyUpdate(long long int root, long long int val, long long int s,
                long long int e, long long int us, long long int ue) {
  if (lazy[root] != 0) {
    tree[root] += lazy[root];
    if (s != e) {
      lazy[2 * root + 1] += lazy[root];
      lazy[2 * root + 2] += lazy[root];
    }
    lazy[root] = 0;
  }
  if (us > e || ue < s) {
    return;
  }
  if (us <= s && ue >= e) {
    tree[root] += val;
    if (s != e) {
      lazy[2 * root + 1] += val;
      lazy[2 * root + 2] += val;
    }
    return;
  }
  long long int mid = (s + e) / 2;
  LazyUpdate(2 * root + 1, val, s, mid, us, ue);
  LazyUpdate(2 * root + 2, val, mid + 1, e, us, ue);
  tree[root] = min(tree[2 * root + 1], tree[2 * root + 2]);
}
long long int LazyRmQ(long long int root, long long int s, long long int e,
                      long long int qs, long long int qe) {
  if (lazy[root] != 0) {
    tree[root] += lazy[root];
    if (s != e) {
      lazy[2 * root + 1] += lazy[root];
      lazy[2 * root + 2] += lazy[root];
    }
    lazy[root] = 0;
  }
  if (qs > e || s > qe) {
    return MAX;
  }
  if (qs <= s && qe >= e) {
    return tree[root];
  }
  long long int mid = (s + e) / 2;
  return min(LazyRmQ(2 * root + 1, s, mid, qs, qe),
             LazyRmQ(2 * root + 2, mid + 1, e, qs, qe));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; ++i) {
    long long int v;
    cin >> v;
    LazyUpdate(0, v, 0, MAXL - 1, i, i);
  }
  char line[100];
  long long int queries;
  cin >> queries;
  cin.ignore();
  for (long long int j = 0; j < queries; ++j) {
    cin.getline(line, 100);
    long long int left, right, val;
    if (istringstream(line) >> left >> right >> val) {
      if (left > right) {
        LazyUpdate(0, val, 0, MAXL - 1, left, n - 1);
        LazyUpdate(0, val, 0, MAXL - 1, 0, right);
      } else
        LazyUpdate(0, val, 0, MAXL - 1, left, right);
    } else {
      if (left > right) {
        cout << min(LazyRmQ(0, 0, MAXL - 1, left, n - 1),
                    LazyRmQ(0, 0, MAXL - 1, 0, right))
             << endl;
      } else
        cout << LazyRmQ(0, 0, MAXL - 1, left, right) << endl;
    }
  }
  return 0;
}
