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 int maxnum = 1e18;
long long int arr[200005];
long long int segtree[800005];
long long int lazy[800005];
void build(int node, int start, int end) {
  if (start == end) {
    segtree[node] = arr[start];
  } else {
    int mid = (start + end) / 2;
    build(2 * node + 1, start, mid);
    build(2 * node + 2, mid + 1, end);
    segtree[node] = min(segtree[2 * node + 1], segtree[2 * node + 2]);
  }
}
void Rangeupdate(int node, int start, int end, int l, int r, int val) {
  if (lazy[node] != 0) {
    segtree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node + 1] += lazy[node];
      lazy[2 * node + 2] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end || l > end || r < start) return;
  if (start >= l and end <= r) {
    segtree[node] += val;
    if (start != end) {
      lazy[2 * node + 1] += val;
      lazy[2 * node + 2] += val;
    }
    return;
  }
  int mid = (start + end) / 2;
  Rangeupdate(2 * node + 1, start, mid, l, r, val);
  Rangeupdate(2 * node + 2, mid + 1, end, l, r, val);
  segtree[node] = min(segtree[2 * node + 1], segtree[2 * node + 2]);
}
long long int query(int node, int start, int end, int l, int r) {
  if (start > end or r < start or l > end) return maxnum;
  if (lazy[node] != 0) {
    segtree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node + 1] += lazy[node];
      lazy[2 * node + 2] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start >= l and end <= r) return segtree[node];
  int mid = (start + end) / 2;
  long long int p1 = query(2 * node + 1, start, mid, l, r);
  long long int p2 = query(2 * node + 2, mid + 1, end, l, r);
  return min(p1, p2);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  int m;
  cin >> m;
  build(0, 0, n - 1);
  int lf, rg, v;
  while (m--) {
    cin >> lf >> rg;
    if (cin.peek() == '\n') {
      if (lf > rg) {
        cout << min(query(0, 0, n - 1, lf, n - 1), query(0, 0, n - 1, 0, rg))
             << endl;
      } else {
        cout << query(0, 0, n - 1, lf, rg) << endl;
      }
    } else {
      cin >> v;
      if (lf > rg) {
        Rangeupdate(0, 0, n - 1, lf, n - 1, v);
        Rangeupdate(0, 0, n - 1, 0, rg, v);
      } else {
        Rangeupdate(0, 0, n - 1, lf, rg, v);
      }
    }
  }
  return 0;
}
