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>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
const long long N = 2e5 + 10;
long long n;
long long a[N];
struct Segment {
  struct Node {
    long long val;
    long long lazy;
  };
  Node seg[4 * N];
  Node merge(Node a, Node b) {
    Node x;
    x.val = min(a.val, b.val);
    x.lazy = 0;
    return x;
  }
  void propagate(long long node, long long start, long long end) {
    seg[node].val += seg[node].lazy;
    if (start != end) {
      seg[2 * node].lazy += seg[node].lazy;
      seg[2 * node + 1].lazy += seg[node].lazy;
    }
    seg[node].lazy = 0;
  }
  void build(long long node, long long start, long long end) {
    if (start == end) {
      seg[node].val = a[start];
      seg[node].lazy = 0;
      return;
    }
    long long mid = (start + end) >> 1;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    seg[node] = merge(seg[2 * node], seg[2 * node + 1]);
  }
  void update(long long node, long long start, long long end, long long l,
              long long r, long long vals) {
    propagate(node, start, end);
    if (l > end or r < start) {
      return;
    }
    if (start >= l and end <= r) {
      seg[node].lazy += vals;
      propagate(node, start, end);
      return;
    }
    long long mid = (start + end) >> 1;
    update(2 * node, start, mid, l, r, vals);
    update(2 * node + 1, mid + 1, end, l, r, vals);
    seg[node] = merge(seg[2 * node], seg[2 * node + 1]);
  }
  long long query(long long node, long long start, long long end, long long l,
                  long long r) {
    propagate(node, start, end);
    if (l > end or r < start) {
      return inf;
    }
    if (start >= l and end <= r) {
      return seg[node].val;
    }
    long long mid = (start + end) >> 1;
    return min(query(2 * node, start, mid, l, r),
               query(2 * node + 1, mid + 1, end, l, r));
  }
};
Segment x;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  x.build(1, 1, n);
  long long m;
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    string s;
    if (i == 0) cin.ignore();
    getline(cin, s);
    stringstream ss(s);
    long long num = 0;
    vector<long long> inp;
    while (ss >> num) {
      inp.push_back(num);
    }
    long long start = inp[0] + 1, end = inp[1] + 1;
    if ((long long)(inp.size()) == 3) {
      long long vals = inp[2];
      if (start > end) {
        x.update(1, 1, n, start, n, vals);
        x.update(1, 1, n, 1, end, vals);
      } else {
        x.update(1, 1, n, start, end, vals);
      }
    } else {
      assert((long long)(inp.size()) == 2);
      if (start > end) {
        cout << min(x.query(1, 1, n, start, n), x.query(1, 1, n, 1, end));
      } else {
        cout << x.query(1, 1, n, start, end);
      }
      cout << '\n';
    }
  }
  return 0;
}
