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 a[600005], b[600005], n, m, lef, righ, x, y, z, minn;
void maintain(int o, int L, int R) {
  int lc = o * 2, rc = o * 2 + 1;
  a[o] = 0;
  if (R > L) {
    a[o] = min(a[lc], a[rc]);
  }
  a[o] += b[o];
}
void update(int o, int L, int R) {
  int lc = o * 2, rc = o * 2 + 1;
  if (lef <= L && righ >= R)
    b[o] += z;
  else {
    int mid = L + (R - L) / 2;
    if (lef <= mid) update(lc, L, mid);
    if (righ > mid) update(rc, mid + 1, R);
  }
  maintain(o, L, R);
}
void query(int o, int L, int R, int add) {
  if (lef <= L && righ >= R) {
    minn = min(minn, a[o] + add);
  } else {
    int mid = L + (R - L) / 2;
    if (lef <= mid) query(o * 2, L, mid, b[o] + add);
    if (righ > mid) query(o * 2 + 1, mid + 1, R, b[o] + add);
  }
}
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &z);
    lef = i, righ = i;
    update(1, 1, 262144);
  }
  scanf("%lld", &m);
  for (int i = 0; i < m; i++) {
    char use;
    scanf("%lld %lld%c", &x, &y, &use);
    x++, y++;
    if (use == '\n') {
      minn = 9223372036854775807;
      if (x <= y)
        lef = x, righ = y, query(1, 1, 262144, 0), printf("%lld\n", minn);
      else {
        lef = x, righ = n;
        query(1, 1, 262144, 0);
        lef = 1, righ = y;
        query(1, 1, 262144, 0);
        printf("%lld\n", minn);
      }
    } else {
      scanf("%lld", &z);
      if (x <= y) {
        lef = x, righ = y;
        update(1, 1, 262144);
      } else {
        lef = x, righ = n;
        update(1, 1, 262144);
        lef = 1, righ = y;
        ;
        update(1, 1, 262144);
      }
    }
  }
}
