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, a[200005], m;
pair<long long, long long> first[800005];
char s[25];
void build(int node, int l, int r) {
  if (l == r) {
    first[node].first = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(node << 1, l, mid);
  build(node << 1 | 1, mid + 1, r);
  first[node].first = min(first[node << 1].first, first[node << 1 | 1].first);
}
void update(int node, int x, int y, int l, int r, long long val) {
  if (first[node].second != 0) {
    first[node].first += first[node].second;
    if (x != y) {
      first[node << 1].second += first[node].second;
      first[node << 1 | 1].second += first[node].second;
    }
    first[node].second = 0;
  }
  if (x > y || x > r || y < l) return;
  if (l <= x && y <= r) {
    first[node].first += val;
    if (x != y) {
      first[node << 1].second += val;
      first[node << 1 | 1].second += val;
    }
    return;
  }
  int mid = x + (y - x) / 2;
  update(node << 1, x, mid, l, r, val);
  update(node << 1 | 1, mid + 1, y, l, r, val);
  first[node] = min(first[node << 1], first[node << 1 | 1]);
}
long long rmq(int node, int x, int y, int l, int r) {
  if (x > y || x > r || y < l) return 10000000000;
  if (first[node].second != 0) {
    first[node].first += first[node].second;
    if (x != y) {
      first[node << 1].second += first[node].second;
      first[node << 1 | 1].second += first[node].second;
    }
    first[node].second = 0;
  }
  if (l <= x && y <= r) return first[node].first;
  int mid = x + (y - x) / 2;
  return min(rmq(node << 1, x, mid, l, r),
             rmq(node << 1 | 1, mid + 1, y, l, r));
}
signed main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  build(1, 1, n);
  cin >> m;
  gets(s);
  for (int i = 0, l, r, v; i < m; ++i) {
    gets(s);
    if (sscanf(s, "%d%d%lld", &l, &r, &v) == 3) {
      if (l <= r)
        update(1, 1, n, l + 1, r + 1, v);
      else {
        update(1, 1, n, 1, r + 1, v);
        update(1, 1, n, l + 1, n, v);
      }
    } else {
      if (l <= r)
        cout << rmq(1, 1, n, l + 1, r + 1) << endl;
      else
        cout << min(rmq(1, 1, n, 1, r + 1), rmq(1, 1, n, l + 1, n)) << endl;
    }
  }
  return 0;
}
