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;
typedef struct node {
  long long left;
  long long right;
  long long min;
  long long incre;
} node;
long long input[200005];
long long n, m;
long long lf, rg, v;
node tree[1000005];
void buildTree(long long node, long long left, long long right) {
  long long mid;
  tree[node].left = left;
  tree[node].right = right;
  if (left == right) {
    tree[node].min = input[left];
    return;
  }
  mid = left / 2 + right / 2;
  buildTree(node * 2, left, mid);
  buildTree(node * 2 + 1, mid + 1, right);
  if (tree[node * 2].min + tree[node * 2].incre <
      tree[node * 2 + 1].min + tree[node * 2 + 1].incre) {
    tree[node].min = tree[node * 2].min + tree[node * 2].incre;
  } else {
    tree[node].min = tree[node * 2 + 1].min + tree[node * 2 + 1].incre;
  }
  return;
}
long long query(long long node, long long left, long long right) {
  long long mid, lRt, rRt;
  if (left <= tree[node].left && tree[node].right <= right) {
    return tree[node].min + tree[node].incre;
  }
  if (tree[node].right < left || right < tree[node].left) {
    return LLONG_MAX;
  }
  lRt = query(node * 2, left, right);
  rRt = query(node * 2 + 1, left, right);
  if (lRt > rRt) {
    return rRt + tree[node].incre;
  } else {
    return lRt + tree[node].incre;
  }
}
void update(long long node, long long left, long long right, long long value) {
  long long lRt, rRt;
  if (left <= tree[node].left && tree[node].right <= right) {
    tree[node].incre += value;
    return;
  }
  if (tree[node].right < left || right < tree[node].left) {
    return;
  }
  update(node * 2, left, right, value);
  update(node * 2 + 1, left, right, value);
  lRt = tree[node * 2].min + tree[node * 2].incre;
  rRt = tree[node * 2 + 1].min + tree[node * 2 + 1].incre;
  if (lRt > rRt) {
    tree[node].min = rRt;
  } else {
    tree[node].min = lRt;
  }
}
int main() {
  cin >> n;
  char temp;
  for (int i = 1; i <= n; i++) {
    cin >> input[i];
  }
  buildTree(1, 1, n);
  cin >> m;
  for (int i = 0; i <= m; i++) {
    cin >> lf >> rg;
    lf++;
    rg++;
    if (getchar() == '\n') {
      if (lf <= rg) {
        cout << query(1, lf, rg) << "\n";
      } else {
        long long r1 = query(1, 1, rg);
        long long r2 = query(1, lf, n);
        if (r1 > r2) {
          cout << r2 << "\n";
        } else {
          cout << r1 << "\n";
        }
      }
      continue;
    } else {
      cin >> v;
      if (lf <= rg) {
        update(1, lf, rg, v);
      } else {
        update(1, 1, rg, v);
        update(1, lf, n, v);
      }
    }
  }
  return 0;
}
