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, mn[1000005], lz[1000005];
char ch;
long long read() {
  ch = getchar();
  long long ff = 1, x = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * ff;
}
void up(long long rt) {
  mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
  return;
}
void bt(long long rt, long long ll, long long rr) {
  if (ll == rr) {
    scanf("%lld", &mn[rt]);
    return;
  }
  long long mid = (ll + rr) >> 1;
  bt(rt << 1, ll, mid);
  bt(rt << 1 | 1, mid + 1, rr);
  up(rt);
  return;
}
void down(long long rt) {
  if (lz[rt] == 0) return;
  lz[rt << 1] += lz[rt];
  lz[rt << 1 | 1] += lz[rt];
  mn[rt << 1] += lz[rt];
  mn[rt << 1 | 1] += lz[rt];
  lz[rt] = 0;
  return;
}
void update(long long rt, long long ll, long long rr, long long L, long long R,
            long long kk) {
  if (ll == L && rr == R) {
    mn[rt] += kk;
    lz[rt] += kk;
    return;
  }
  long long mid = (ll + rr) >> 1;
  down(rt);
  if (R <= mid)
    update(rt << 1, ll, mid, L, R, kk);
  else if (L > mid)
    update(rt << 1 | 1, mid + 1, rr, L, R, kk);
  else
    update(rt << 1, ll, mid, L, mid, kk),
        update(rt << 1 | 1, mid + 1, rr, mid + 1, R, kk);
  up(rt);
  return;
}
long long query(long long rt, long long ll, long long rr, long long L,
                long long R) {
  if (ll == L && rr == R) return mn[rt];
  long long mid = (ll + rr) >> 1;
  down(rt);
  if (R <= mid)
    return query(rt << 1, ll, mid, L, R);
  else if (L > mid)
    return query(rt << 1 | 1, mid + 1, rr, L, R);
  else
    return min(query(rt << 1, ll, mid, L, mid),
               query(rt << 1 | 1, mid + 1, rr, mid + 1, R));
}
int main() {
  scanf("%lld", &n);
  bt(1, 1, n);
  scanf("%lld", &m);
  while (m--) {
    long long x = read(), y = read(), flag = 0;
    x++;
    y++;
    long long z = 0, ff = 1;
    while (ch != '\n') {
      if (ch == '-')
        ff = -1, flag = 1;
      else if (ch >= '0' && ch <= '9')
        flag = 1, z = z * 10 + ch - '0';
      ch = getchar();
    }
    z = ff * z;
    if (flag) {
      if (x <= y)
        update(1, 1, n, x, y, z);
      else
        update(1, 1, n, 1, y, z), update(1, 1, n, x, n, z);
    } else {
      if (x <= y)
        printf("%lld\n", query(1, 1, n, x, y));
      else
        printf("%lld\n", min(query(1, 1, n, 1, y), query(1, 1, n, x, n)));
    }
  }
  return 0;
}
