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 int maxn = 200010;
long long Min[maxn << 2], add[maxn << 2];
int n;
void build(int l, int r, int rt) {
  if (l == r)
    scanf("%I64d", Min + rt);
  else {
    int m = (l + r) >> 1;
    build(l, m, rt << 1);
    build(m + 1, r, rt << 1 | 1);
    Min[rt] = min(Min[rt << 1], Min[rt << 1 | 1]);
  }
}
void push_down(int rt) {
  if (add[rt]) {
    Min[rt << 1] += add[rt];
    Min[rt << 1 | 1] += add[rt];
    add[rt << 1] += add[rt];
    add[rt << 1 | 1] += add[rt];
    add[rt] = 0;
  }
}
void update(int x, int y, int v, int l, int r, int rt) {
  if (x <= l && y >= r)
    add[rt] += v, Min[rt] += v;
  else {
    push_down(rt);
    int m = (l + r) >> 1;
    if (x <= m) update(x, y, v, l, m, rt << 1);
    if (y > m) update(x, y, v, m + 1, r, rt << 1 | 1);
    Min[rt] = min(Min[rt << 1], Min[rt << 1 | 1]);
  }
}
long long ask(int x, int y, int l, int r, int rt) {
  if (x <= l && y >= r)
    return Min[rt];
  else {
    push_down(rt);
    int m = (l + r) >> 1;
    long long ans = (long long)1e18;
    if (x <= m) ans = min(ask(x, y, l, m, rt << 1), ans);
    if (y > m) ans = min(ask(x, y, m + 1, r, rt << 1 | 1), ans);
    return ans;
  }
}
int main() {
  scanf("%d", &n);
  n--;
  build(0, n, 1);
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r, v;
    scanf("%d%d", &l, &r);
    if (getchar() == ' ') {
      scanf("%d", &v);
      if (l > r) {
        update(l, n, v, 0, n, 1);
        update(0, r, v, 0, n, 1);
      } else
        update(l, r, v, 0, n, 1);
    } else {
      long long ans = (long long)1e18;
      if (l > r) {
        ans = min(ask(l, n, 0, n, 1), ask(0, r, 0, n, 1));
      } else
        ans = ask(l, r, 0, n, 1);
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
