#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <time.h>
#include <vector>
#include <chrono>
#include <sstream>
#include <queue>
#include <map>
#include <limits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <random>
#include <assert.h>

using namespace std;

struct Pair {
    bool existance = false;
    int val;
    int index;
};

struct Zero {
    int index;
    int left;
    int right;
};


bool CheckForAnswer(int n, Zero nul, Pair left, Pair right) {
    if ((!left.existance) & (!right.existance)) {
        if (nul.index == 0 || nul.index == n-1) {
            return true;
        }
        if (nul.left * nul.right == -1) {
            return true;
        }
        if (nul.left != left.val) {
            return true;
        }
        return false;
    }
    if (left.existance && (!right.existance)) {
        if (nul.index == n-1) {
            return false;
        }
        if (nul.left * nul.right == 1) {
            if (nul.left == left.val) {
                return false;
            }
            int meet = (nul.index + left.index) / 2;
            return meet <= n / 2;
        }
        if (nul.left != left.val) {
            int meet = (nul.index + left.index) / 2;
            return meet <= n / 2;
        }
        int meet = (nul.index + left.index) / 2;
        return meet < n / 2;
    }

    if ((!left.existance) && right.existance) {
        if (nul.index == 0) {
            return false;
        }
        if (nul.left * nul.right == 1) {
            if (nul.right == right.val) {
                return false;
            }
            int meet = (nul.index + right.index) / 2;
            return meet >= n / 2;
        }
        if (nul.right != right.val) {
            int meet = (nul.index + right.index) / 2;
            return meet >= n / 2;
        }
        int meet = (nul.index + right.index) / 2;
        return meet >= n / 2;
    }
    if (left.index >= n/2 || right.index <= n/2) {
        return false;
    }
    if (nul.left * nul.right == 1) {
        if (nul.left == left.val) {
            if (nul.right == right.val) {
                return false;
            }
            int meet2 = (left.index + right.index)/2;
            int meet1 = (nul.index + right.index)/2;
            return (n/2 <= meet1) & (n/2 > meet2);
        }
        if (nul.right == right.val) {
            int meet1 = (left.index + nul.index) / 2;
            int meet2 = (left.index + right.index)/2;
            return (n/2 >= meet1) & (n/2  <= meet2);
        }
        int meet2 = (nul.index + right.index)/2;
        int meet1 = (left.index + nul.index) / 2;
        return (n/2 >= meet1) & (n/2 <= meet2);
    }
    if (nul.left == left.val) {
        // doesn't matter same with right or not
        int meet1 = (nul.index + left.index) / 2;
        int meet2 = (nul.index + right.index) / 2;
        return (n/2 > meet1) & (n/2 <= meet2);
    }
    int meet1 = (nul.index + left.index) / 2;
    int meet2 = (nul.index + right.index) / 2;
    return (n/2 >= meet1) & (n/2 <= meet2);
}


void CountPairs(vector<Pair>* left, vector<Pair>* right, const vector<int>& per) {
    int N = static_cast<int> (per.size());
    for (int i = 0; i < N; ++i) {
        (*right)[i] = {0, 2, -1};
        (*left)[i] = {0, (per[0] > per[i]) * 2 - 1, 0};
        for (int j = i + 1; j < N - 1; ++j) {
            if (per[j] > per[i] && per[j+1] > per[i]) {
                (*right)[i] = {true, 1, j};
                break;
            }
            if (per[j] < per[i] && per[j+1] < per[i]) {
                (*right)[i] = {true, -1, j};
                break;
            }
        }
        for (int j = i - 1; j > 0; --j) {
            if (per[j] > per[i] && per[j-1] > per[i]) {
                (*left)[i] = {true, 1, j};
                break;
            }
            if (per[j] < per[i] && per[j-1] < per[i]) {
                (*left)[i] = {true, -1, j};
                break;
            }
        }
    }
}

void CountPairs2(vector<Pair>* left, vector<Pair>* right, const vector<int>& per) {
    int N = static_cast<int> (per.size());
    vector<int>inv(N);
    for (int i = 0; i < N; ++i) {
        inv[per[i] - 1] = i;
    }
    map<int, int> pairs_right;
    map<int, int> pairs_left;
    vector<int> ones(N, 1);
    for (int i = 0; i < N - 1; ++i) {
        pairs_right[i] = 1;
    }
    for (int i = 1; i < N; ++i) {
        pairs_left[-i] = 1;
    }
    for (int i = 0; i < N; ++i) {
        int cur = inv[i];
        ones[cur] = 0;
        pairs_right.erase(cur);
        if (cur != 0) {
            pairs_right.erase(cur - 1);
        }
        pairs_left.erase(-cur);
        if (cur != N - 1) {
            pairs_left.erase(-(cur + 1));
        }
        auto right_pair = pairs_right.upper_bound(cur);
        auto left_pair = pairs_left.upper_bound(-cur);
        if (right_pair != pairs_right.end()) {
            (*right)[cur] = {true, right_pair->second, right_pair->first};
        } else {
            (*right)[cur] = {false, 2, -1};
        }
        if (left_pair != pairs_left.end()) {
            (*left)[cur] = {true, left_pair->second, -left_pair->first};
        } else {
            (*left)[cur] = {false, (per[0] > per[cur]) * 2 - 1, -1};
        }
        ones[cur] = -1;
        if (cur > 0 && ones[cur - 1] == -1) {
            pairs_right[cur - 1] = -1;
            pairs_left[-cur] = -1;
        }
        if (cur < N - 1 && ones[cur + 1] == -1) {
            pairs_right[cur] = -1;
            pairs_left[-(cur + 1)] = -1;
        }
    }
}

int Desision(const vector<int>& per) {
    int N = static_cast<int> (per.size());
    vector<Pair> left(N);
    vector<Pair> right(N);
    CountPairs2(&left, &right, per);
    for (int i = 0; i < N; ++i) {
        Zero cur = {i, 1, 1};
        if (i > 0) {
            cur.left = (per[i - 1] > per[i]) * 2 - 1;
        }
        if (i < N - 1) {
            cur.right = (per[i + 1] > per[i]) * 2 - 1;
        }
        bool can = CheckForAnswer(N, cur, left[i], right[i]);
        if (can) {
            return per[i];
        }
    }
    return -1;
}


int Med(int a, int b, int c) {
    vector<int> trio = {a, b, c};
    sort(trio.begin(), trio.end());
    return trio[1];
}

int Desision2(const vector<int> inp) {
    vector<int> res;
    vector<int> start = inp;
    vector<int>* pointer1 = &start;
    vector<int>* pointer2 = &res;
    while (true) {
        for (int i = 1; i < (*pointer1).size() - 1; ++i) {
            (*pointer2).push_back(Med((*pointer1)[i], (*pointer1)[i - 1], (*pointer1)[i + 1]));
        }
        (*pointer1).clear();
        if ((*pointer2).size() == 1) {
            return (*pointer2)[0];
        }
        swap(pointer1, pointer2);
    }
}

void Show(const vector<int>& x) {
    for (const auto & y: x) {
        cout << y <<" ";
    }
    cout << '\n';
}

int main2() {
    int k = 100000;
    for (int i = 0; i < k; ++i) {
        int n = rand() % 15 + 2;
        //cin >> n;
        int N = 2*n - 1;
        vector<int> per(N);
        for (int j = 1; j <= N; ++j) {
            per[j - 1] = j;
        }
        random_shuffle(per.begin(), per.end());
        int ans1 = Desision(per);
        int ans2 = Desision2(per);
        if (ans1 != ans2) {
            cout << ans1 << " " << ans2 << '\n';
            Show(per);
            break;
        } else {
            cout << i << " OK" << '\n';
        }
    }

    return 0;
}

int main() {
    int n;
    cin >> n;
    int N = 2 * n - 1;
    vector<int> per(N);
    for (auto & x: per) {
        cin >> x;
    }
    cout << Desision(per);
    return 0;
}

Measured memory_bytes: 26112