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 MAX_N = 2e5 + 10, INF = 1e9;
long long n, a[MAX_N], m;
long long seg[4 * MAX_N], lazy[4 * MAX_N];
void shift(long long id, long long b, long long e) {
  lazy[id * 2] += lazy[id];
  lazy[id * 2 + 1] += lazy[id];
  long long mid = (b + e) / 2;
  seg[id * 2] += lazy[id];
  seg[id * 2 + 1] += lazy[id];
  lazy[id] = 0;
}
void upd(long long id, long long b, long long e, long long l, long long r,
         long long val) {
  if (e <= l || r <= b) return;
  if (l <= b && e <= r) {
    lazy[id] += val;
    seg[id] = seg[id] + val;
    return;
  }
  shift(id, b, e);
  long long mid = (b + e) / 2;
  upd(id * 2, b, mid, l, r, val);
  upd(id * 2 + 1, mid, e, l, r, val);
  seg[id] = min(seg[id * 2], seg[id * 2 + 1]);
}
long long get(long long id, long long b, long long e, long long l,
              long long r) {
  if (e <= l || r <= b) return INF * 10000;
  if (l <= b && e <= r) {
    return seg[id];
  }
  shift(id, b, e);
  long long mid = (b + e) / 2;
  return min(get(id * 2, b, mid, l, r), get(id * 2 + 1, mid, e, l, r));
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    upd(1, 1, n + 1, i, i + 1, a[i]);
  }
  scanf("%lld", &m);
  int z, x, y;
  while (m--) {
    scanf("%lld %lld", &z, &x);
    z++;
    x++;
    bool type = (getchar() == ' ');
    if (type) {
      scanf("%lld", &y);
      if (z <= x) {
        upd(1, 1, n + 1, z, x + 1, y);
      } else {
        upd(1, 1, n + 1, 1, x + 1, y);
        upd(1, 1, n + 1, z, n + 1, y);
      }
    } else {
      if (z <= x) {
        printf("%lld\n", get(1, 1, n + 1, z, x + 1));
      } else {
        printf("%lld\n",
               min(get(1, 1, n + 1, 1, x + 1), get(1, 1, n + 1, z, n + 1)));
      }
    }
  }
}
