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;
struct tree {
  int l, r;
  long long minn, lazy;
};
tree t[800004];
int a[200001];
int temp, n, m, i, l, r, s;
void pushdown(int id) {
  long long temp = t[id].lazy;
  int l = id * 2, r = id * 2 + 1;
  t[l].lazy += temp;
  t[r].lazy += temp;
  t[l].minn += temp;
  t[r].minn += temp;
  t[id].lazy = 0;
}
void buildtree(int id, int l, int r) {
  if (l == r) {
    t[id].l = l;
    t[id].r = r;
    t[id].minn = a[l];
    t[id].lazy = 0;
  } else {
    int mid = (l + r) / 2;
    t[id].l = l;
    t[id].r = r;
    t[id].lazy = 0;
    buildtree(id * 2, l, mid);
    buildtree(id * 2 + 1, mid + 1, r);
    t[id].minn = min(t[id * 2].minn, t[id * 2 + 1].minn);
  }
}
void add(int id, int l, int r, int s) {
  if ((t[id].l == l) && (t[id].r == r)) {
    t[id].lazy += (long long)s;
    t[id].minn += (long long)s;
  } else {
    int mid = (t[id].l + t[id].r) / 2;
    if (t[id].lazy != 0) pushdown(id);
    if (r <= mid)
      add(id * 2, l, r, s);
    else if (mid < l)
      add(id * 2 + 1, l, r, s);
    else {
      add(id * 2, l, mid, s);
      add(id * 2 + 1, mid + 1, r, s);
    }
    t[id].minn = min(t[id * 2].minn, t[id * 2 + 1].minn);
  }
}
long long query(int id, int l, int r) {
  if ((t[id].l == l) && (t[id].r == r)) {
    return t[id].minn;
  } else {
    int mid = (t[id].l + t[id].r) / 2;
    if (t[id].lazy != 0) pushdown(id);
    if (mid < l) return query(id * 2 + 1, l, r);
    if (r <= mid) return query(id * 2, l, r);
    return min(query(id * 2, l, mid), query(id * 2 + 1, mid + 1, r));
  }
}
int main() {
  char key;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  buildtree(1, 1, n);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d%c", &l, &r, &key);
    if (l <= r) {
      if (key == ' ') {
        scanf("%d", &s);
        add(1, l + 1, r + 1, s);
      } else
        printf("%I64d\n", query(1, l + 1, r + 1));
    } else {
      if (key == ' ') {
        scanf("%d", &s);
        add(1, l + 1, n, s);
        add(1, 1, r + 1, s);
      } else
        printf("%I64d\n", min(query(1, l + 1, n), query(1, 1, r + 1)));
    }
  }
  return 0;
}
