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;
long long n, m, l, r, x;
const long long N = 200010, inf = 1e18;
long long tr[N << 2], lz[N << 2];
char ch;
inline long long read() {
  long long res = 0;
  char ch = getchar();
  bool XX = false;
  for (; !isdigit(ch); ch = getchar()) (ch == '-') && (XX = true);
  for (; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
  return XX ? -res : res;
}
void build(long long k, long long l, long long r) {
  if (l == r) {
    tr[k] = read();
    return;
  }
  build((k << 1), l, ((l + r) >> 1));
  build(((k << 1) | 1), ((l + r) >> 1) + 1, r);
  tr[k] = min(tr[(k << 1)], tr[((k << 1) | 1)]);
}
void cd(long long k) {
  tr[(k << 1)] += lz[k];
  lz[(k << 1)] += lz[k];
  tr[((k << 1) | 1)] += lz[k];
  lz[((k << 1) | 1)] += lz[k];
  lz[k] = 0;
}
long long ask(long long k, long long l, long long r, long long x, long long y) {
  if (x <= l && r <= y) return tr[k];
  if (lz[k]) cd(k);
  long long res = inf;
  if (x <= ((l + r) >> 1))
    res = min(res, ask((k << 1), l, ((l + r) >> 1), x, y));
  if (((l + r) >> 1) + 1 <= y)
    res = min(res, ask(((k << 1) | 1), ((l + r) >> 1) + 1, r, x, y));
  return res;
}
void change(long long k, long long l, long long r, long long x, long long y,
            long long val) {
  if (x <= l && r <= y) {
    tr[k] += val;
    lz[k] += val;
    return;
  }
  if (lz[k]) cd(k);
  if (x <= ((l + r) >> 1)) change((k << 1), l, ((l + r) >> 1), x, y, val);
  if (((l + r) >> 1) + 1 <= y)
    change(((k << 1) | 1), ((l + r) >> 1) + 1, r, x, y, val);
  tr[k] = min(tr[(k << 1)], tr[((k << 1) | 1)]);
}
signed main() {
  cin >> n;
  build(1, 1, n);
  cin >> m;
  while (m--) {
    scanf("%lld%lld", &l, &r);
    l++;
    r++;
    ch = getchar();
    if (ch == '\n') {
      if (l <= r)
        cout << ask(1, 1, n, l, r) << endl;
      else
        cout << min(ask(1, 1, n, 1, r), ask(1, 1, n, l, n)) << endl;
    } else {
      x = read();
      if (l <= r)
        change(1, 1, n, l, r, x);
      else
        change(1, 1, n, 1, r, x), change(1, 1, n, l, n, x);
    }
  }
  return 0;
}
