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 mx = 200000;
const long long mod = 1e9 + 7;
long long A[mx + 5], prop[8 * mx + 5], tree[4 * mx + 5];
void s_tree(long long node, long long L, long long R) {
  if (L == R) {
    tree[node] = A[L];
    return;
  }
  long long mid = (L + R) / 2;
  long long left = (node * 2);
  long long right = (node * 2) + 1;
  s_tree(left, L, mid);
  s_tree(right, mid + 1, R);
  tree[node] = min(tree[left], tree[right]);
}
void propgation(long long node, long long l, long long r) {
  if (l != r) {
    prop[node * 2] += prop[node];
    prop[node * 2 + 1] += prop[node];
  }
  tree[node] += prop[node];
  prop[node] = 0;
}
void update(long long node, long long l, long long r, long long v, long long L,
            long long R) {
  propgation(node, L, R);
  if (L > r || R < l) {
    return;
  }
  if (l <= L && R <= r) {
    prop[node] = v;
    propgation(node, L, R);
    return;
  }
  long long mid = (L + R) / 2;
  long long left = (node * 2);
  long long right = (node * 2) + 1;
  update(left, l, r, v, L, mid);
  update(right, l, r, v, mid + 1, R);
  tree[node] = min(tree[left], tree[right]);
}
long long query(long long node, long long l, long long r, long long L,
                long long R) {
  propgation(node, L, R);
  if (L > r || R < l) {
    return INT_MAX;
  }
  if (l <= L && R <= r) {
    return tree[node];
  }
  long long mid = (L + R) / 2;
  long long left = (node * 2);
  long long right = (node * 2 + 1);
  long long r1 = 0, r2 = 0;
  r1 = query(left, l, r, L, mid);
  r2 = query(right, l, r, mid + 1, R);
  return min(r1, r2);
}
void solve() {
  int t = 1;
  while (t--) {
    long long n;
    scanf("%lld", &n);
    for (long long i = 1; i <= n; i++) {
      scanf("%lld", &A[i]);
    }
    s_tree(1, 1, n);
    long long q;
    scanf("%lld", &q);
    getchar();
    for (long long i = 0; i < q; i++) {
      string s;
      getline(std ::cin, s);
      stringstream ss(s);
      long long x;
      vector<long long> v;
      while (ss >> x) {
        v.push_back(x);
      }
      if (v.size() == 2) {
        long long a, b;
        a = v[0], b = v[1];
        if (a > b) {
          long long ans1, ans2;
          ans1 = query(1, a + 1, n, 1, n);
          ans2 = query(1, 1, b + 1, 1, n);
          printf("%lld", min(ans1, ans2));
        } else {
          printf("%lld", query(1, a + 1, b + 1, 1, n));
        }
        printf("\n");
      } else {
        long long a, b, c;
        a = v[0], b = v[1], c = v[2];
        if (a > b) {
          update(1, a + 1, n, c, 1, n);
          update(1, 1, b + 1, c, 1, n);
        } else {
          update(1, a + 1, b + 1, c, 1, n);
        }
      }
    }
  }
}
int main() {
  solve();
  return 0;
}
