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;
const long long int MAXN = 1000005;
long long int Tree[4 * MAXN], lazy[4 * MAXN];
long long int N, A[MAXN];
void build(long long int node, long long int start, long long int end) {
  if (start == end) {
    Tree[node] = A[start];
  } else {
    long long int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    Tree[node] = min(Tree[2 * node], Tree[2 * node + 1]);
  }
}
void update(long long int node, long long int start, long long int end,
            long long int l, long long int r, long long int v) {
  if (lazy[node] != 0) {
    Tree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end || l > end || r < start) return;
  if (l <= start && end <= r) {
    Tree[node] += v;
    if (start != end) {
      lazy[2 * node] += v;
      lazy[2 * node + 1] += v;
    }
    return;
  }
  long long int mid = (start + end) / 2;
  update(2 * node, start, mid, l, r, v);
  update(2 * node + 1, mid + 1, end, l, r, v);
  Tree[node] = min(Tree[2 * node], Tree[2 * node + 1]);
}
long long int query(long long int node, long long int start, long long int end,
                    long long int l, long long int r) {
  if (lazy[node] != 0) {
    Tree[node] += lazy[node];
    if (start != end) {
      lazy[2 * node] += lazy[node];
      lazy[2 * node + 1] += lazy[node];
    }
    lazy[node] = 0;
  }
  if (start > end || l > end || r < start) return 1000000000000000000;
  if (l <= start && end <= r) {
    return Tree[node];
  }
  long long int mid = (start + end) / 2;
  long long int left = 1000000000000000000, right = 1000000000000000000;
  if (l <= mid) left = query(2 * node, start, mid, l, r);
  if (mid + 1 <= r) right = query(2 * node + 1, mid + 1, end, l, r);
  return min(left, right);
}
int main() {
  scanf("%lld", &N);
  fill_n(lazy, 4 * MAXN, 0);
  fill_n(Tree, 4 * MAXN, 1000000000000000000);
  for (long long int i = 1; i <= N; i++) {
    scanf("%lld", &A[i]);
  }
  build(1, 1, N);
  long long int M;
  long long int l, r, z;
  scanf("%lld", &M);
  string dum;
  getline(cin, dum);
  while (M--) {
    string line;
    getline(cin, line);
    stringstream ss(line);
    ss >> l >> r;
    if ((ss >> z)) {
      ++l, ++r;
      if (l <= r) {
        update(1, 1, N, l, r, z);
      } else {
        update(1, 1, N, 1, r, z);
        update(1, 1, N, l, N, z);
      }
    } else {
      ++l, ++r;
      if (l <= r) {
        long long int ans = query(1, 1, N, l, r);
        printf("%lld\n", ans);
      } else {
        long long int ans = query(1, 1, N, 1, r);
        ans = min(ans, query(1, 1, N, l, N));
        printf("%lld\n", ans);
      }
    }
  }
}
