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;
int b1[] = {0, 0, 1, -1};
int b2[] = {1, -1, 0, 0};
int d1[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int d2[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int lazy[4 * 200000 + 1] = {0};
void build_tree(long long int *a, long long int s, long long int e,
                long long int *tree, long long int index) {
  if (s == e) {
    tree[index] = a[s];
    return;
  }
  long long int mid = (s + e) / 2;
  build_tree(a, s, mid, tree, 2 * index);
  build_tree(a, mid + 1, e, tree, 2 * index + 1);
  tree[index] = min(tree[2 * index], tree[2 * index + 1]);
  return;
}
void updateRangeLazy(long long *tree, long long second, long long se,
                     long long l, long long r, long long inc, long long index) {
  if (lazy[index] != 0) {
    tree[index] += lazy[index];
    if (second != se) {
      lazy[2 * index] += lazy[index];
      lazy[2 * index + 1] += lazy[index];
    }
    lazy[index] = 0;
  }
  if (second > r or l > se) {
    return;
  }
  if (second >= l && se <= r) {
    tree[index] += inc;
    if (second != se) {
      lazy[2 * index] += inc;
      lazy[2 * index + 1] += inc;
    }
    return;
  }
  long long mid = (second + se) / 2;
  updateRangeLazy(tree, second, mid, l, r, inc, 2 * index);
  updateRangeLazy(tree, mid + 1, se, l, r, inc, 2 * index + 1);
  tree[index] = min(tree[2 * index], tree[2 * index + 1]);
  return;
}
long long queryLazy(long long *tree, long long second, long long se,
                    long long qs, long long qe, long long index) {
  if (lazy[index] != 0) {
    tree[index] += lazy[index];
    if (second != se) {
      lazy[2 * index] += lazy[index];
      lazy[2 * index + 1] += lazy[index];
    }
    lazy[index] = 0;
  }
  if (second > qe or se < qs) {
    return INT_MAX;
  }
  if (second >= qs and se <= qe) {
    return tree[index];
  }
  int mid = (second + se) / 2;
  int left = queryLazy(tree, second, mid, qs, qe, 2 * index);
  int right = queryLazy(tree, mid + 1, se, qs, qe, 2 * index + 1);
  return min(left, right);
}
void solve() {
  long long n;
  scanf("%lld", &n);
  long long a[n];
  for (long long i = 0; i < n; i++) scanf("%lld", &a[i]);
  long long tree[4 * n + 1];
  memset((tree), 0, sizeof(tree));
  build_tree(a, 0, n - 1, tree, 1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    char ch;
    scanf("%d%d", &l, &r);
    scanf("%c", &ch);
    if (ch == ' ') {
      long long val;
      scanf("%lld", &val);
      if (l <= r) {
        updateRangeLazy(tree, 0, n - 1, l, r, val, 1);
      } else {
        updateRangeLazy(tree, 0, n - 1, l, n - 1, val, 1);
        updateRangeLazy(tree, 0, n - 1, 0, r, val, 1);
      }
    } else {
      if (l <= r) {
        cout << queryLazy(tree, 0, n - 1, l, r, 1) << endl;
      } else {
        cout << min(queryLazy(tree, 0, n - 1, l, n - 1, 1),
                    queryLazy(tree, 0, n - 1, 0, r, 1))
             << endl;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
