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;
int N;
long long tree1[2 * (1 << 18)], tree2[2 * (1 << 18)];
char buf[100];
long long rmq(int id, int L, int R, int low, int high) {
  if (low <= L && high >= R) {
    return tree1[id];
  } else {
    int M = (L + R) / 2;
    long long ans = (1ll << 60);
    if (low < M) ans = min(ans, rmq(id * 2, L, M, low, high));
    if (high > M) ans = min(ans, rmq(id * 2 + 1, M, R, low, high));
    return ans + tree2[id];
  }
}
void inc(int id, int L, int R, int low, int high, long long d) {
  if (low <= L && high >= R) {
    tree1[id] += d;
    tree2[id] += d;
  } else {
    int M = (L + R) / 2;
    if (low < M) inc(id * 2, L, M, low, high, d);
    if (high > M) inc(id * 2 + 1, M, R, low, high, d);
    tree1[id] = min(tree1[id * 2], tree1[id * 2 + 1]) + tree2[id];
  }
}
long long rmq2(int low, int high) {
  if (low <= high) {
    return rmq(1, 0, (1 << 18), low, high + 1);
  } else {
    return min(rmq(1, 0, (1 << 18), low, N), rmq(1, 0, (1 << 18), 0, high + 1));
  }
}
void inc2(int low, int high, long long d) {
  if (low <= high) {
    inc(1, 0, (1 << 18), low, high + 1, d);
  } else {
    inc(1, 0, (1 << 18), low, N, d);
    inc(1, 0, (1 << 18), 0, high + 1, d);
  }
}
int main(void) {
  int Q, i, j;
  scanf(" %d ", &N);
  for ((i) = 0; (i) < (int)(N); (i)++) {
    int tmp;
    scanf(" %d ", &tmp);
    inc2(i, i, tmp);
  }
  scanf(" %d ", &Q);
  for ((i) = 0; (i) < (int)(Q); (i)++) {
    gets(buf);
    string s = buf;
    istringstream ss(s);
    vector<int> v;
    int tmp;
    while (ss >> tmp) v.push_back(tmp);
    if (v.size() == 2) {
      long long ans = rmq2(v[0], v[1]);
      printf("%I64d\n", ans);
    } else {
      inc2(v[0], v[1], v[2]);
    }
  }
  return 0;
}
