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;
void built(long long int s, long long int e, long long int *arr,
           long long int *tree, long long int pos) {
  if (s == e) {
    tree[pos] = arr[s];
    return;
  }
  int mid = (s + e) / 2;
  built(s, mid, arr, tree, 2 * pos);
  built(mid + 1, e, arr, tree, 2 * pos + 1);
  tree[pos] = min(tree[2 * pos], tree[2 * pos + 1]);
  return;
}
void update(long long int s, long long int e, long long int *tree,
            long long int *lazy, long long int pos, long long int sq,
            long long int eq, long long int val) {
  if (lazy[pos] != 0) {
    tree[pos] += lazy[pos];
    if (s != e) {
      lazy[2 * pos + 1] += lazy[pos];
      lazy[2 * pos] += lazy[pos];
    }
    lazy[pos] = 0;
  }
  if (s > eq || sq > e) {
    return;
  }
  if (s >= sq && e <= eq) {
    tree[pos] += val;
    if (s != e) {
      lazy[pos * 2] += val;
      lazy[2 * pos + 1] += val;
    }
    return;
  }
  long long int mid = (s + e) / 2;
  update(s, mid, tree, lazy, 2 * pos, sq, eq, val);
  update(mid + 1, e, tree, lazy, 2 * pos + 1, sq, eq, val);
  tree[pos] = min(tree[pos * 2], tree[2 * pos + 1]);
}
long long int query(long long int s, long long int e, long long int *tree,
                    long long int *lazy, long long int pos, long long int sq,
                    long long int eq) {
  if (lazy[pos] != 0) {
    tree[pos] += lazy[pos];
    if (s != e) {
      lazy[2 * pos + 1] += lazy[pos];
      lazy[2 * pos] += lazy[pos];
    }
    lazy[pos] = 0;
  }
  if (s > eq || sq > e) {
    return pow(10, 12LL);
  }
  if (s >= sq && e <= eq) {
    return tree[pos];
  }
  long long int mid = (s + e) / 2;
  long long int a = query(s, mid, tree, lazy, 2 * pos, sq, eq);
  long long int b = query(mid + 1, e, tree, lazy, 2 * pos + 1, sq, eq);
  return min(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int arr[n + 1];
  long long int tree[4 * n];
  long long int lazy[4 * n];
  memset(lazy, 0, sizeof(lazy));
  for (long long int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long int pos = 1;
  built(1, n, arr, tree, pos);
  long long int q;
  cin >> q;
  for (long long int k = 1; k <= q; k++) {
    long long int L, R, Val;
    cin >> L >> R;
    L++, R++;
    if (cin.get() == ' ') {
      cin >> Val;
      if (L <= R) {
        update(1, n, tree, lazy, 1, L, R, Val);
      } else {
        update(1, n, tree, lazy, 1, L, n, Val);
        update(1, n, tree, lazy, 1, 1, R, Val);
      }
    } else {
      long long int ans = 0;
      if (L <= R) {
        ans = query(1, n, tree, lazy, 1, L, R);
      } else {
        ans = min(query(1, n, tree, lazy, 1, L, n),
                  query(1, n, tree, lazy, 1, 1, R));
      }
      cout << ans << endl;
    }
  }
}
