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 INF = 2e17;
long long seg[200000 * 4 + 100];
long long lazy[200000 * 4 + 100];
void shift(int id, int b, int e) {
  lazy[id * 2] += lazy[id];
  lazy[(id * 2) + 1] += lazy[id];
  seg[id * 2] += lazy[id];
  seg[(id * 2) + 1] += lazy[id];
  lazy[id] = 0;
}
void upd(int b, int e, int r, int l, int val, int id = 1) {
  if (l <= b || r >= e) return;
  if (r <= b && l >= e) {
    seg[id] += val;
    lazy[id] += val;
    return;
  }
  shift(id, b, e);
  int m = (e + b) / 2;
  upd(b, m, r, l, val, id * 2);
  upd(m, e, r, l, val, (id * 2) + 1);
  seg[id] = min(seg[id * 2], seg[(id * 2) + 1]);
}
long long get(int b, int e, int r, int l, int id = 1) {
  if (l <= b || r >= e) return INF;
  if (r <= b && l >= e) return seg[id];
  shift(id, b, e);
  int m = (e + b) / 2;
  return min(get(b, m, r, l, id * 2), get(m, e, r, l, (id * 2) + 1));
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    upd(0, n, i, i + 1, t);
  }
  int m;
  cin >> m;
  while (m--) {
    int r, l, val;
    scanf("%d %d", &r, &l);
    bool typ = (getchar() == ' ');
    if (!typ) {
      if (r > l)
        cout << min(get(0, n, 0, l + 1), get(0, n, r, n)) << '\n';
      else
        cout << get(0, n, r, l + 1) << '\n';
      continue;
    }
    cin >> val;
    if (r > l) {
      upd(0, n, 0, l + 1, val);
      upd(0, n, r, n, val);
    } else
      upd(0, n, r, l + 1, val);
  }
}
