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 st[800000], added[800000];
int arr[200010];
void build(int node, int L, int R) {
  if (L == R)
    st[node] = arr[L];
  else {
    int mid = (L + R) / 2;
    build(node * 2, L, mid);
    build(node * 2 + 1, mid + 1, R);
    st[node] = min(st[node * 2], st[node * 2 + 1]);
  }
}
void update(int node, int L, int R, int i, int j, long long val,
            long long acc) {
  added[node] += acc;
  st[node] += acc;
  if (L > j || R < i) return;
  if (L >= i && R <= j) {
    added[node] += val;
    st[node] += val;
    return;
  }
  int mid = (L + R) / 2;
  update(node * 2, L, mid, i, j, val, added[node]);
  update(node * 2 + 1, mid + 1, R, i, j, val, added[node]);
  added[node] = 0;
  st[node] = min(st[node * 2], st[node * 2 + 1]);
  return;
}
long long rmq(int node, int L, int R, int i, int j, long long acc) {
  if (L > j || R < i) return 1 << 30;
  if (L >= i && R <= j) return st[node] + acc;
  int mid = (L + R) / 2;
  long long rmqL = rmq(node * 2, L, mid, i, j, acc + added[node]);
  long long rmqR = rmq(node * 2 + 1, mid + 1, R, i, j, acc + added[node]);
  return min(rmqL, rmqR);
}
int main() {
  memset(st, 0, sizeof st);
  memset(added, 0, sizeof added);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> arr[i];
  int Q;
  cin >> Q;
  build(1, 0, N - 1);
  scanf("\n");
  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    string s;
    getline(cin, s);
    int a = atoi(s.c_str());
    if (int((s).size())) {
      if (x > y) {
        update(1, 0, N - 1, x, N - 1, a, 0);
        update(1, 0, N - 1, 0, y, a, 0);
      } else
        update(1, 0, N - 1, x, y, a, 0);
    } else {
      if (x > y) {
        cout << min(rmq(1, 0, N - 1, x, N - 1, 0), rmq(1, 0, N - 1, 0, y, 0))
             << endl;
      } else
        cout << rmq(1, 0, N - 1, x, y, 0) << endl;
    }
  }
}
