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
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CCircularRMQ solver = new CCircularRMQ();
    solver.solve(1, in, out);
    out.close();
  }

  static class CCircularRMQ {

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      long[] arr = in.nextLongArray(n);
      CCircularRMQ.SegTree tree = new CCircularRMQ.SegTree(n, arr);
      int q = in.nextInt();
      while (q-- > 0) {
        String[] qq = in.nextLine().split("\\s+");
        if (qq.length == 3) {
          int a = Integer.parseInt(qq[0]);
          int b = Integer.parseInt(qq[1]);
          int c = Integer.parseInt(qq[2]);
          if (a <= b) {
            tree.update(1, 0, n - 1, a, b, c);
          } else {
            tree.update(1, 0, n - 1, 0, b, c);
            tree.update(1, 0, n - 1, a, n - 1, c);
          }
        } else {
          int a = Integer.parseInt(qq[0]);
          int b = Integer.parseInt(qq[1]);
          if (a <= b) {
            out.println(tree.query(1, 0, n - 1, a, b));
          } else {
            out.println(
                Math.min(
                    tree.query(1, 0, n - 1, 0, b),
                    tree.query(1, 0, n - 1, a, n - 1)
                )
            );
          }
        }
      }
    }

    static class SegTree {

      long[] tree;
      long[] lazy;
      long[] arr;

      SegTree(int n, long[] arr) {
        tree = new long[5 * n + 1];
        lazy = new long[5 * n + 1];
        this.arr = arr;
        build(1, 0, n - 1);
      }

      void build(int root, int l, int r) {
        if (l == r) {
          tree[root] = arr[l];
          return;
        }
        int mid = (l + r) >> 1;
        build(root << 1, l, mid);
        build(root << 1 | 1, mid + 1, r);
        merge(root);
      }

      void update(int root, int l, int r, int a, int b, long v) {
        if (r < a || b < l) {
          return;
        }
        if (a <= l && r <= b) {
          lazy[root] += v;
          return;
        }
        push(root);
        int mid = (l + r) >> 1;
        update(root << 1, l, mid, a, b, v);
        update(root << 1 | 1, mid + 1, r, a, b, v);
        merge(root);
      }

      long query(int root, int l, int r, int a, int b) {
        if (r < a || b < l) {
          return Long.MAX_VALUE;
        }
        if (a <= l && r <= b) {
          return tree[root] + lazy[root];
        }
        push(root);
        int mid = (l + r) >> 1;
        long left = query(root << 1, l, mid, a, b);
        long right = query(root << 1 | 1, mid + 1, r, a, b);
        merge(root);
        return Math.min(left, right);
      }

      void push(int root) {
        lazy[root << 1] += lazy[root];
        lazy[root << 1 | 1] += lazy[root];
        lazy[root] = 0;
      }

      void merge(int root) {
        tree[root] = Math
            .min(tree[root << 1] + lazy[root << 1], tree[root << 1 | 1] + lazy[root << 1 | 1]);
      }

    }

  }

  static class InputReader {

    BufferedReader reader;
    InputStream in;
    StringTokenizer tok;

    public InputReader(InputStream in) {
      this.in = in;
      this.reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(in, 1 << 16)));
    }

    public String next() {
      while (tok == null || !tok.hasMoreTokens()) {
        try {
          tok = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          return null;
        }
      }
      return tok.nextToken();
    }

    public String nextLine() {
      try {
        return reader.readLine();
      } catch (IOException e) {
        return null;
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long[] nextLongArray(int n) {
      long[] res = new long[n];
      for (int i = 0; i < n; ++i) {
        res[i] = nextInt();
      }
      return res;
    }
  }

}

