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>
template <size_t E, bool T = 1>
class FastScanner {
  char e[E | 1], *t, *a;
  const double A = strtod("NaN", nullptr);
  FILE* o;
  bool i() {
    size_t n = fread(e, 1, E, o);
    e[n] = 0;
    a = e + n;
    t = e;
    return n;
  }
  bool i(ptrdiff_t n) {
    size_t s = fread(e, 1, E, o);
    e[n += s] = 0;
    a = e + n;
    t = e;
    return s;
  }

 public:
  FastScanner(FILE* o = stdin) : e{}, t(e), a(e + E), o(o) { i(); }
  bool scan(double& n) {
    if (!*t && !i()) {
      n = A;
      return 0;
    }
    char* s;
    n = strtod(t, &s);
    while (s == t)
      if (!i()) {
        n = A;
        return 0;
      }
    if (s >= a) {
      ptrdiff_t h = a - t;
      memcpy(e, t, h);
      if (i(h)) n = strtod(e, &t);
    }
    return 1;
  }
  bool scan(char& n) {
    n = *t++;
    if (n) return 1;
    if (!i()) return 0;
    n = *t++;
    return 1;
  }
  bool scan(char* n) {
    char* s = nullptr;
    for (;; ++t) {
      char h = *t;
      if (!h) {
        if (s) {
          ptrdiff_t r = t - s;
          memcpy(n, s, r);
          n += r;
        }
        if (!i()) {
          *n = 0;
          return s;
        }
        h = *e;
        if (s) s = e;
      }
      if (!isspace(h)) {
        if (!s) {
          s = t;
        }
      } else if (s) {
        ptrdiff_t r = t - s;
        memcpy(n, s, r);
        n[r] = 0;
        ++t;
        return 1;
      }
    }
  }
  template <class O, bool I = T>
  bool scan(O& n,
            typename std::enable_if<std::is_signed<O>::value>::type* _1 = 0,
            typename std::enable_if<I>::type* _2 = 0) {
    bool s = 0, h = 0;
    n = 0;
    for (;; ++t) {
      char r = *t;
      if (!r) {
        if (!i()) return s;
        r = *t;
      }
      if (isdigit(r)) {
        s = 1;
        n = n * 10 + r - '0';
      } else if (s) {
        ++t;
        break;
      } else if (r == '-') {
        h = 1;
      }
    }
    if (h) n = -n;
    return 1;
  }
  template <class O, bool I = T>
  bool scan(O& n,
            typename std::enable_if<std::is_signed<O>::value>::type* _1 = 0,
            typename std::enable_if<!I>::type* _2 = 0) {
    bool s = 0, h = 0;
    n = 0;
    for (;; ++t) {
      char r = *t;
      if (!r) {
        if (!i()) return s;
        r = *t;
      }
      if (isdigit(r)) {
        s = 1;
        n = n * 10 + r - '0';
      } else if (s) {
        break;
      } else if (r == '-') {
        h = 1;
      }
    }
    if (h) n = -n;
    return 1;
  }
  template <class O, bool I = T>
  bool scan(O& n,
            typename std::enable_if<!std::is_signed<O>::value>::type* _1 = 0,
            typename std::enable_if<I>::type* _2 = 0) {
    bool s = 0;
    n = 0;
    for (;; ++t) {
      char h = *t;
      if (!h) {
        if (!i()) return s;
        h = *t;
      }
      if (isdigit(h)) {
        s = 1;
        n = n * 10 + h - '0';
      } else if (s) {
        ++t;
        return 1;
      }
    }
  }
  template <class O, bool I = T>
  bool scan(O& n,
            typename std::enable_if<!std::is_signed<O>::value>::type* _1 = 0,
            typename std::enable_if<!I>::type* _2 = 0) {
    bool s = 0;
    n = 0;
    for (;; ++t) {
      char h = *t;
      if (!h) {
        if (!i()) return s;
        h = *t;
      }
      if (isdigit(h)) {
        s = 1;
        n = n * 10 + h - '0';
      } else if (s) {
        return 1;
      }
    }
  }
  template <class O, class... I>
  bool scan(O&& n, I&&... s) {
    return scan(n) && scan(s...);
  }
  bool scanln(char* n) {
    char *s = t, *h = n;
    for (;; ++t) {
      char r = *t;
      if (!r) {
        ptrdiff_t d = t - s;
        memcpy(h, s, d);
        h += d;
        if (!i()) {
          *h = 0;
          return h - n;
        }
        s = e;
        r = *e;
      }
      if (r == '\n') {
        ++t;
        ptrdiff_t d = t - s;
        memcpy(h, s, d);
        h[d] = 0;
        return 1;
      }
    }
  }
  template <class O, class... I>
  bool scanln(O&& n, I&&... s) {
    return scanln(n) && scanln(s...);
  }
  char peek() {
    if (!*t) i();
    return *t;
  }
  bool ignore(char n) {
    for (;; ++t) {
      if (!*t && !i()) return 0;
      if (*t - n) return 1;
    }
  }
  bool ignore() {
    for (;; ++t) {
      if (!*t && !i()) return 0;
      if (!isspace(*t)) return 1;
    }
  }
  bool advance() {
    if (!*t && !i()) return 0;
    return *++t;
  }
  bool advance(ptrdiff_t n) {
    if (!*t && !i()) return 0;
    for (ptrdiff_t s = a - t; s <= n;) {
      n -= s;
      if (!i()) return 0;
      s = a - t;
    }
    t += n;
    return *t;
  }
  template <class O>
  O next() {
    O n;
    scan(n);
    return n;
  }
  template <class O>
  FastScanner& operator>>(O& n) {
    scan(n);
    return *this;
  }
};
template <size_t E>
class FastPrinter {
  char e[E | 1], *t, *a;
  const char T[6] = "%.16f";
  const size_t A = 20, O = 330;
  FILE* o;
  void i() {
    fwrite(e, 1, t - e, o);
    t = e;
  }

 public:
  FastPrinter(FILE* o) : e{}, t(e), a(t + E), o(o) {}
  void print(double n) {
    char s[O];
    size_t h = sprintf(s, T, n);
    char* r = t + h;
    if (r >= a) {
      i();
      r = e + h;
    }
    memcpy(t, s, h);
    t = r;
  }
  void print(char n) {
    if (t + 1 >= a) i();
    *t++ = n;
  }
  void print(char* n) {
    size_t s = strlen(n);
    char* h = t + s;
    if (h >= a) {
      i();
      h = e + s;
    }
    if (s >= E) {
      fwrite(n, 1, s, o);
      return;
    }
    memcpy(t, n, s);
    t = h;
  }
  void print(const char* n) {
    size_t s = strlen(n);
    char* h = t + s;
    if (h >= a) {
      i();
      h = e + s;
    }
    if (s >= E) {
      fwrite(n, 1, s, o);
      return;
    }
    memcpy(t, n, s);
    t = h;
  }
  template <size_t I>
  void print(const char (&n)[I]) {
    size_t s = I - 1;
    char* h = t + s;
    if (h >= a) {
      i();
      h = e + s;
    }
    if (s >= E) {
      fwrite(n, 1, s, o);
      return;
    }
    memcpy(t, n, s);
    t = h;
  }
  template <class I>
  void print(I n,
             typename std::enable_if<std::is_signed<I>::value>::type* _ = 0) {
    if (t + A >= a) i();
    if (!n) {
      *t++ = '0';
      return;
    }
    char s[A], *h = s + A, *r = h;
    if (n < 0) {
      *t++ = '-';
      n = -n;
    }
    while (n) {
      *--h = n % 10 + '0';
      n /= 10;
    }
    memcpy(t, h, r - h);
    t += r - h;
  }
  template <class I>
  void print(I n,
             typename std::enable_if<!std::is_signed<I>::value>::type* _ = 0) {
    if (t + A >= a) i();
    if (!n) {
      *t++ = '0';
      return;
    }
    char s[A], *h = s + A, *r = h;
    while (n) {
      *--h = n % 10 + '0';
      n /= 10;
    }
    memcpy(t, h, r - h);
    t += r - h;
  }
  template <class I, class... N>
  void print(I n, N&&... s) {
    print(n), print(s...);
  }
  template <class I>
  void println(I n) {
    print(n, '\n');
  }
  template <class I, class... N>
  void println(I n, N&&... s) {
    print(n, ' '), println(s...);
  }
  template <class I>
  void printlns(I n) {
    print(n, '\n');
  }
  template <class I, class... N>
  void printlns(I n, N&&... s) {
    print(n, '\n'), printlns(s...);
  }
  void flush() {
    fwrite(e, 1, t - e, o);
    fflush(o);
    t = e;
  }
  template <class I>
  FastPrinter& operator<<(I n) {
    print(n);
    return *this;
  }
  ~FastPrinter() { flush(); }
};
constexpr size_t BUF_SIZE = (1 << 17);
FastScanner<BUF_SIZE> cin(stdin);
FastPrinter<BUF_SIZE> cout(stdout);
class SegmentTree {
  static const int64_t inf = 1LL << 61;
  size_t n;
  std::vector<int64_t> tree, oft, num;
  auto pow2_least(size_t n) -> size_t {
    size_t m;
    for (m = 1; m <= n; m <<= 1) {
    }
    return m;
  }
  void modify(size_t l, size_t r, int64_t x, size_t i, size_t a, size_t b) {
    if (r <= a || b <= l) return;
    if (l <= a && b <= r) {
      oft[i] += x;
      return;
    }
    size_t c = (a + b) >> 1;
    modify(l, r, x, i << 1 | 0, a, c);
    modify(l, r, x, i << 1 | 1, c, b);
    int64_t lch = oft[i << 1 | 0] + tree[i << 1 | 0];
    int64_t rch = oft[i << 1 | 1] + tree[i << 1 | 1];
    if (lch < rch) {
      num[i] = num[i << 1 | 0];
      tree[i] = lch;
    } else if (lch > rch) {
      num[i] = num[i << 1 | 1];
      tree[i] = rch;
    } else {
      num[i] = num[i << 1 | 0] + num[i << 1 | 1];
      tree[i] = lch;
    }
  }
  std::pair<int64_t, int> query(size_t l, size_t r, size_t i, size_t a,
                                size_t b) {
    if (r <= a || b <= l) return {inf, 0};
    if (l <= a && b <= r) return {oft[i] + tree[i], num[i]};
    size_t c = (a + b) >> 1;
    auto lch = query(l, r, i << 1 | 0, a, c);
    auto rch = query(l, r, i << 1 | 1, c, b);
    if (lch.first < rch.first) {
      lch.first += oft[i];
      return lch;
    } else if (lch.first > rch.first) {
      rch.first += oft[i];
      return rch;
    } else {
      lch.first += oft[i];
      lch.second += rch.second;
      return lch;
    }
  }

 public:
  SegmentTree(size_t m)
      : n(pow2_least(m)), tree(n << 1), oft(n << 1), num(n << 1, 1) {}
  void modify(size_t l, size_t r, int64_t x) { modify(l, r, x, 1, 0, n); }
  std::pair<int64_t, int> query(size_t l, size_t r) {
    return query(l, r, 1, 0, n);
  }
};
int main() {
  size_t n;
  cin.scan(n);
  SegmentTree tree(n);
  for (size_t i = 0; i < n; ++i) {
    int64_t a;
    cin.scan(a);
    tree.modify(i, i + 1, a);
  }
  int m;
  cin.scan(m);
  for (int i = 0; i < m; ++i) {
    size_t lf, rg;
    cin.scan(lf);
    cin.scan<size_t, false>(rg);
    if (cin.peek() == '\n') {
      if (lf <= rg) {
        cout.println(tree.query(lf, rg + 1).first);
      } else if (rg + 1 == lf) {
        cout.println(tree.query(0, n).first);
      } else {
        int64_t l = tree.query(lf, n).first;
        int64_t r = tree.query(0, rg + 1).first;
        cout.println(std::min(l, r));
      }
    } else {
      int64_t v;
      cin.scan(v);
      if (lf <= rg) {
        tree.modify(lf, rg + 1, v);
      } else if (rg + 1 == lf) {
        tree.modify(0, n, v);
      } else {
        tree.modify(lf, n, v);
        tree.modify(0, rg + 1, v);
      }
    }
  }
  return 0;
}
