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 N_MAX = 2e5 + 1;
long long segment_tree[4 * N_MAX + 1];
long long lazy_tree[4 * N_MAX + 1];
int N, M;
void propagate(int node) {
  segment_tree[2 * node] += lazy_tree[node];
  segment_tree[2 * node + 1] += lazy_tree[node];
  lazy_tree[2 * node] += lazy_tree[node];
  lazy_tree[2 * node + 1] += lazy_tree[node];
  lazy_tree[node] = 0;
}
void update(int value, int a, int b, int left = 1, int right = N,
            int node = 1) {
  if (a <= left && right <= b) {
    segment_tree[node] += value;
    lazy_tree[node] += value;
    return;
  }
  propagate(node);
  int middle = (left + right) / 2;
  if (a <= middle) {
    update(value, a, b, left, middle, node * 2);
  }
  if (b > middle) {
    update(value, a, b, middle + 1, right, node * 2 + 1);
  }
  segment_tree[node] = min(segment_tree[node * 2], segment_tree[node * 2 + 1]);
}
long long rmq(int a, int b, int left = 1, int right = N, int node = 1) {
  if (a <= left && right <= b) {
    return segment_tree[node];
  }
  propagate(node);
  long long MIN = 1e16;
  int middle = (left + right) / 2;
  if (a <= middle) {
    MIN = min(MIN, rmq(a, b, left, middle, node * 2));
  }
  if (b > middle) {
    MIN = min(MIN, rmq(a, b, middle + 1, right, node * 2 + 1));
  }
  segment_tree[node] = min(segment_tree[node * 2], segment_tree[node * 2 + 1]);
  return MIN;
}
long long get_number(string s, size_t &poz) {
  long long answer = 0;
  bool negative = false;
  if (s[poz] == '-') {
    ++poz;
    negative = true;
  }
  while (poz < s.size() && s[poz] != ' ') {
    answer = answer * 10 + (s[poz] - '0');
    ++poz;
  }
  if (negative == true) answer *= -1;
  return answer;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    long long value;
    cin >> value;
    update(value, i, i);
  }
  cin >> M;
  cin.ignore();
  for (int i = 1; i <= M; ++i) {
    string line;
    getline(cin, line);
    int cnt_spaces = 0;
    for (size_t j = 0; j < line.size(); ++j) {
      if (line[j] == ' ') cnt_spaces++;
    }
    if (cnt_spaces == 1) {
      long long a, b;
      size_t poz = 0;
      a = get_number(line, poz) + 1;
      ++poz;
      b = get_number(line, poz) + 1;
      if (b >= a) {
        cout << rmq(a, b) << '\n';
      } else {
        cout << min(rmq(1, b), rmq(a, N)) << '\n';
      }
    } else {
      long long a, b, v;
      size_t poz = 0;
      a = get_number(line, poz) + 1;
      ++poz;
      b = get_number(line, poz) + 1;
      ++poz;
      v = get_number(line, poz);
      if (b >= a) {
        update(v, a, b);
      } else {
        update(v, 1, b);
        update(v, a, N);
      }
    }
  }
}
