/+ dub.sdl:
    name "A"
    dependency "dcomp" version=">=0.0.2"
+/

import std.algorithm, std.range, std.stdio, std.math, std.conv, core.bitop;

// import dcomp.scanner;
// import dcomp.algorithm;

int main() {
    import std.conv;
	auto sc = new Scanner();
    int n;
    int[] ai;
    sc.read(n, ai);

    bool solve(int md) {
        bool[] a = ai.map!(a => (md <= a)).array;
        int l = n-1;
        while (l) {
            if (a[l-1] == a[l]) break;
            l--;
        }
        int r = n-1;
        while (r < 2*n-2) {
            if (a[r] == a[r+1]) break;
            r++;
        }
        if ((n-1)-l < r-(n-1)) {
            return !a[l];
        } else {
            return !a[r];
        }
    }

    writeln(binSearch!(solve)(0, 2*n+10)-1);
	return 0;
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */
// module dcomp.scanner;

class Scanner {
    import std.stdio : File, readln, stdin;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeString, isDynamicArray;
    import std.algorithm : map;
    File f;
    this(File f = stdin) {
        this.f = f;
    }
    string[] buf;
    bool succ() {
        while (!buf.length) {
            if (f.eof) return false;
            buf = readln.split;
        }
        return true;
    }
    int read(Args...)(auto ref Args args) {
        foreach (i, ref v; args) {
            if (!succ()) return i;
            alias VT = typeof(v);
            static if (!isSomeString!VT && isDynamicArray!VT) {
                v = buf.map!(to!(ElementType!VT)).array;
                buf.length = 0;
            } else {
                v = buf.front.to!VT;
                buf.popFront();
            }
        }
        return args.length;
    }
}
/* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/algorithm.d */
// module dcomp.algorithm;

template binSearch(alias pred) {
    T binSearch(T)(T l, T r) {
        while (r-l > 1) {
            int md = (l+r)/2;
            if (!pred(md)) l = md;
            else r = md;
        }
        return r;
    }
}
