stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define int long long

using namespace std;

int read(){

    int x=0,f=1;char ch=getchar();

    for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;

    for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';

    return x*f;

}

const int N=2e5+28;

int n,a[N],b[N];

signed main(){

    //freopen("night.in","r",stdin);

    //freopen("night.out","w",stdout);

    n=read()*2-1;

    for(int i=1;i<=n;i++)a[i]=read();

    int l=0,r=0x7fffffff,ans=0x7fffffff;

    while(l<=r){

	int mid=(l+r)>>1;

	for(int i=1;i<=n;i++)

	    b[i]=(a[i]>mid);

	int p1=n/2,p2=n/2+2;

	int re=-1;

	for(;p1;p1--,p2++){

	    if(b[p1]==b[p1+1]){

		re=b[p1];

		break;

	    }

	    if(b[p2]==b[p2-1]){

		re=b[p2];

		break;

	    }

	}

	if(re==-1)re=b[1];

	if(re==0)ans=mid,r=mid-1;

	else l=mid+1;

    }

    printf("%lld",ans);

    return 0;

}

/*

7

1 2 3 4 3 2 1

5

1 9 2 3 6

*/


// Faster C++ solution for the same problem (measured speedup: 5.1473214814823125x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include <vector>

#include <stdio.h>

#include <cstdlib>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



const int N = 5e5 + 10;



inline void Read(int &x) {

	x = 0; register char cc = '\0'; int fff = 1;

	for (; cc < '0' || cc > '9'; cc = getchar())

		if (cc == '-') fff = -1;

	for (; cc >= '0' && cc <= '9'; cc = getchar())

		x = (x << 1) + (x << 3) + (cc & 15);

	x *= fff;

}



int n, mxn, a[N], b[N];



inline int Check(int x) {

	for (int i = 1; i <= mxn; ++i)

		if (a[i] <= x) b[i] = 0;

		else b[i] = 1;

	if (mxn == 1) return b[1];

	//printf("%d : ", x);

	//for (int i = 1; i <= mxn; ++i) printf("%d ", b[i]);

	//printf("\n");

	for (int i = 0; i < n - 1; ++i) {

		if (b[n - i] == b[n - i - 1]) return b[n - i];

		if (b[n + i] == b[n + i + 1]) return b[n + i];

	}

	if (n & 1 /*mxn & 1*/) return b[n];

	else return (!b[n]);

}



int main()

{

	Read(n);

	mxn = n * 2 - 1;

	for (int i = 1; i <= mxn; ++i) Read(a[i]);

	int L = 1, R = mxn/* n */, mid = 0, fps = 0;

	while (L <= R) {

		mid = (L + R) >> 1;

		if (!Check(mid)) {

			fps = mid;

			R = mid - 1;

		}

		else L = mid + 1;

	}

	printf("%d\n", fps);

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.150829123854993x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

int n,ans,a[20000001];

int check1(int i,int j,int x){return a[i]<=x&&a[j]<=x;}

int check2(int i,int j,int x){return a[i]>x&&a[j]>x;} 

int check(int x)

{

    for(int i=0;i<n-1;i++)

	{

        if(check2(n+i,n+i+1,x)||check2(n-i,n-i-1,x))return 0;

        if(check1(n+i,n+i+1,x)||check1(n-i,n-i-1,x))return 1;

    }

    return check1(1,1,x);

}

int main()

{

	scanf("%d",&n);

	for(int i=1;i<=n*2-1;i++)scanf("%d",&a[i]);

	int l=1,r=n*2-1;

	while(l<=r)

	{

		int mid=(l+r)>>1;

		if(check(mid))	r=mid-1,ans=mid;

		else			l=mid+1;

	}

	printf("%d",ans);return 0; 

}

// Faster C++ solution for the same problem (measured speedup: 5.162700954587935x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define LL long long 

using namespace std;



inline int read(){

	int res=0,f=1;char ch=' ';

	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}

	while(isdigit(ch)){res=res*10+ch-'0';ch=getchar();}

	return res*f;

}

const int N=200005;

int n;

int a[N];

inline bool big(int i,int j,int mid){

	return a[i]>mid&&a[j]>mid;

}

inline bool small(int i,int j,int mid){

	return a[i]<=mid&&a[j]<=mid;

}

inline bool check(int mid){

	for(register int i=0;i<n-1;i++){

		if(big(n+i,n+i+1,mid)||big(n-i,n-i-1,mid)) return false;

		if(small(n+i,n+i+1,mid)||small(n-i,n-i-1,mid)) return true;

	}

	return small(1,1,mid);

}

int main(){

	n=read();

	for(register int i=1;i<=n*2-1;i++) a[i]=read();

	int l=0,r=2*n-1,ans=0;

	while(l<=r){

		int mid=(l+r)/2;

		if(check(mid)){

			r=mid-1;ans=mid;

		}

		else l=mid+1;

	}

	printf("%d\n",ans);

	return 0;

}

/*

7

1 2

3 1

3 4

5 4

4 7

6 2

3

1

2

3

*/

// Faster C++ solution for the same problem (measured speedup: 5.149718589372506x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include <cmath>

#include <queue>

#include <cstdio>

#include <vector>

#include <cstring>

#include <iostream>

#include <algorithm>

#define il inline 

#define re register

#define LL long long

using namespace std;

const int mod = 1e9 + 7;

const int INF = (1 << 30);

const int maxn = 2e5 + 50;

LL read() {

    LL res = 0, f = 1; char ch = ' ';

    while (!isdigit(ch)) { ch = getchar(); if (ch == '-') f = -1; } 

    while (isdigit(ch)) res = (res << 3) + (res << 1) + ch - '0', ch = getchar();

    return res * f;

}



int n, a[maxn], ans;

bool Check(int k) {

	for (re int i = 0; i < n - 1; ++i) {

		if ((a[n + i] > k && a[n + i + 1] > k) || (a[n - i] > k && a[n - i - 1] > k)) return 0;

		if ((a[n + i] <= k && a[n + i + 1] <= k) || (a[n - i] <= k && a[n - i - 1] <= k)) return 1;

	}

	return a[1] <= k;

}

int main() {

	n = read();

	for (re int i = 1; i < 2 * n; ++i) a[i] = read();

	int l = 1, r = 2 * n - 1;

	while (l <= r) {

		int mid = (l + r >> 1);

		if (Check(mid)) r = mid - 1, ans = mid;

		else l = mid + 1;

	}

	printf("%d\n", ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.147462244727876x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int N =2e5+10;

int n,a[N];

inline int read()

{

    int x = 0, f = 1; char ch = getchar();

    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }

    while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); }

    return x * f;

}

inline bool check(const int &k)

{

    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;

    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;

    for(int i=1;i<n-1;i++){

        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;

        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;

    }

    return a[1]<=k;

}



int main(){

    n=read();

    for(int i=1;i<n<<1;i++)a[i]=read();

    int l=1,r=(n<<1)-1;

    while(l<r){

        int mid=l+r>>1;

        if(check(mid))

            r=mid;

        else

            l=mid+1;

    }

    printf("%d",l);

}


// Faster C++ solution for the same problem (measured speedup: 5.146853362881463x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n,a[200005];

int check(int x) 

{

	 for(register int i=0;i<n-1;i++) 

	 {

	 	if((a[n+i]>x&&a[n+i+1]>x)||(a[n-i]>x&&a[n-i-1]>x)) return 0;

	 	else if((a[n+i]<=x&&a[n+i+1]<=x)||(a[n-i]<=x&&a[n-i-1]<=x)) return 1;

	 }

	 return a[1]<=x;

}

int main() 

{

	scanf("%d",&n);

	for(register int i=1;i<=2*n-1;i++)

	{

		scanf("%d",&a[i]);

	}

	int ans=0;

	int l=0,r=2*n-1;

	while(l<=r)

	{

		int mid=(l+r)/2;

		if(check(mid))

		{

			r=mid-1;

			ans=mid;

		}

		else 

		{

			l=mid+1;

		}

	}

	printf("%d",ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.204055165200066x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
/*************************************************************************

	> File Name: pyramid.cpp

	> Author: wangyifan

	> Created Time: 2019年11月07日 星期四 08时33分17秒

 ************************************************************************/



#include<iostream>

#include<cstdio>

#include<algorithm>

#define ll long long

#define REP(i,a,b) for(register int i = a;i <= b;++i)

using namespace std;

const int maxn = 1e6+10;

int a[maxn],b[maxn];

int ans,n,num;

inline int read(){

	int res = 0,tmp = 1;

	char ch = getchar();

	while(ch < '0' || ch > '9'){if(ch == '-')tmp = -1;ch = getchar();}

	while(ch >= '0' && ch <= '9')res = (res<<1)+(res<<3)+(ch^48),ch = getchar();

	return res*tmp;

}

inline bool check(int x){

	REP(i,1,num)b[i] = a[i]>x;

	REP(i,0,n-1){

		if((b[n+i] && b[n+i+1]) || (b[n-i] && b[n-i-1]))return false;

		if((!b[n+i] && !b[n+i+1]) || (!b[n-i] && !b[n-i-1]))return true;

	}

	return a[1] <= x;

}

int main(){

	n = read();

	num = (n<<1)-1;

	REP(i,1,num)a[i] = read();

	int l = 1,r = num;

	while(l < r){

		int mid = (l+r)>>1;

		if(check(mid))ans = mid,r = mid;

		else l = mid+1;

	}

	cout<<ans<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.166645971109277x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
/*************************************************************************

	> File Name: pyramid.cpp

	> Author: codecode

	> Created Time: 2019年11月07日 星期四 08时31分48秒

 ************************************************************************/



#include<bits/stdc++.h>

using namespace std;

const int maxn=1000000+5;

int n,a[maxn];

inline int read(){

	int s=0,w=1;

	char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}

	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();

	return s*w;

}

inline bool jujuakioi(const int &k){

	 if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;

	 if((a[n-1]>k&&a[n]>k)||(a[n]>k&&a[n+1]>k))return 0;

	 for(int i=1;i<n-1;i++){

		 if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;

		 if((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k))return 0;

	 }

	 return a[1]<=k;

}

int main(){

	cin>>n;

	for(int i=1;i<n*2;i++)a[i]=read();

	int l=1,r=n*2-1;

	while(l<r){

		int mid=(l+r)/2;

		if(jujuakioi(mid))r=mid;

		else l=mid+1;

	}

	cout<<l;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2139105259100536x):
#include<stdio.h>

const int maxn=1000005;

int i,j,k,m,n,l,r;

int a[maxn];

int check(int x){

	for(int i=n,j=n;i>1&&j<m;i--,j++){

		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))

			return 1;

		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))

			return 0;

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

	m=(n<<1)-1;

	for(i=1;i<=m;i++)

		scanf("%d",&a[i]);

	l=0,r=m+1;

	while(l+1<r){

		int mid=(l+r)>>1;

		if(check(mid))

			r=mid;

		else l=mid;

	}

	printf("%d\n",r);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int n,a[20000010];

bool x(int i,int j,int k) {

    return a[i]<=k&&a[j]<=k;

}

bool y(int i,int j,int k){

    return a[i]>k&&a[j]>k;

} 

bool check(int a){

    for(int i=0;i<n-1;i++){

        if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;

        if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;

    }

    return x(1,1,a);

}

int main(){

    scanf("%d",&n);

    for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);

    int l=1,r=2*n-1,mid;

    while(l<r){

	 	mid=(l+r)/2;

        if(check(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d",l);

    return 0; 

}

// Faster C++ solution for the same problem (measured speedup: 5.160439573117323x):
#include<cstdio>

#include<cstring>

int a[2001000];

int b[2001000];

int n,L;

void turn(int x)//<=x的是0，>x的是1

{

    for(int i=1;i<=L;i++)

        if(a[i]<=x)

            b[i]=0;

        else

            b[i]=1;

}

int main()

{

    scanf("%d",&n);

    L=(n<<1)-1;

    for(int i=1;i<=L;i++)

        scanf("%d",&a[i]);

    int l=1,r=L,mid;

    while(l<r)

    {

        int flag=0;

        mid=(l+r>>1);

        turn(mid);

        for(int i=1;i<n;i++)

        {

            if(b[n+i]==b[n+i-1])

            {

                if(b[n+i]==0)

                    r=mid;

                else

                    l=mid+1;

                flag=1;

                break;

            }

            if(b[n-i]==b[n-i+1])

            {

                if(b[n-i]==0)

                    r=mid;

                else

                    l=mid+1;

                flag=1;

                break;

            }

        }

        if(!flag)

        {

            if(b[n]^(n&1)^1)

                l=mid+1;

            else

                r=mid;

        }

    }

    printf("%d\n",l);

    return 0;

}
// Slower C++ solution:
#include<algorithm>

#include<iostream>

#include<cstring>

#include<cstdio>

#include<cmath>

#define LL long long

#define M 400020

using namespace std;

int read(){

	int nm=0,fh=1;char cw=getchar();

	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;

	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');

	return nm*fh;

}

int n,m,L,R,md,t[M],ans,p[M],t1,t2;

bool solve(int x){

	t1=0,t2=(n<<1);

	for(int i=1;i<=m;i++) p[i]=(t[i]>=x);

	for(int i=2;i<=n;i++) if(p[i]==p[i-1]) t1=i;

	for(int i=m-1;i>=n;i--) if(p[i]==p[i+1]) t2=i;

	if(t1==n||t2==n) return p[n]>0;

	if(t1>1&&t2<m&&p[t1]==p[t2]) return p[t1]>0;

	if(t2-n<n-t1) return p[t2]>0;

	if(t2-n>n-t1) return p[t1]>0;

	return (p[n]^(n&1)^1)>0;

}

int main(){

	n=read(),L=1,R=n,R<<=1,R--,m=R;

	for(int i=1;i<=n+n-1;i++) t[i]=read();

    while(L<=R){

    	md=(L+R>>1);

    	if(!solve(md)) R=md-1;

		else L=md+1,ans=md;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.150051956744277x):
#include<cstdio>

#include<cstring>

int a[2001000];

int b[2001000];

int n,L;

void turn(int x)//<=x的是0，>x的是1

{

    for(int i=1;i<=L;i++)

        if(a[i]<=x)

            b[i]=0;

        else

            b[i]=1;

}

int main()

{

    scanf("%d",&n);

    L=(n<<1)-1;

    for(int i=1;i<=L;i++)

        scanf("%d",&a[i]);

    int l=1,r=L,mid;

    while(l<r)

    {

        int flag=0;

        mid=(l+r>>1);

        turn(mid);

        for(int i=1;i<n;i++)

        {

            if(b[n+i]==b[n+i-1])

            {

                if(b[n+i]==0)

                    r=mid;

                else

                    l=mid+1;

                flag=1;

                break;

            }

            if(b[n-i]==b[n-i+1])

            {

                if(b[n-i]==0)

                    r=mid;

                else

                    l=mid+1;

                flag=1;

                break;

            }

        }

        if(!flag)

        {

            if(b[n]^(n&1)^1)

                l=mid+1;

            else

                r=mid;

        }

    }

    printf("%d\n",l);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int n,a[20000010];

bool x(int i,int j,int k) {

    return a[i]<=k&&a[j]<=k;

}

bool y(int i,int j,int k){

    return a[i]>k&&a[j]>k;

} 

bool check(int a){

    for(int i=0;i<n-1;i++){

        if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;

        if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;

    }

    return x(1,1,a);

}

int main(){

    scanf("%d",&n);

    for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);

    int l=1,r=2*n-1,mid;

    while(l<r){

	 	mid=(l+r)/2;

        if(check(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d",l);

    return 0; 

}

// Faster C++ solution for the same problem (measured speedup: 5.252470720944912x):
#include <cstdio>

#include <cctype>

#include <algorithm>

#define big(i, j) (a[i] >= x && a[j] >= x)

#define small(i, j) (a[i] < x && a[j] < x)

using namespace std;



int a[200005];

int n;



inline void in(register int &x){

	register char ch;

	x = 0;

	while(isspace(ch = getchar()));

	do x = x*10 + ch-'0'; while(isdigit(ch = getchar()));

}



bool check(int x){

	for(int i=1; i<n; i++){

		if(big(n-i, n-i+1) || big(n+i, n+i-1)) return true;

		if(small(n-i, n-i+1) || small(n+i, n+i-1)) return false;

	}

	return a[1] >= x;

}



int main(){

//	freopen("at2165.in", "r", stdin);

//	freopen("at2165.out", "w", stdout);

	in(n);

	for(int i=1; i<=n*2-1; i++)

		in(a[i]);

	int l = 1, r = n * 2 - 1, mid, ans;

	while(l <= r){

		mid = (l+r) >> 1;

		if(check(mid)){

//			printf("%d is valid.\n", mid);

			ans = mid;

			l = mid + 1;

		}

		else r = mid - 1;//, printf("%d is invaild.\n", mid);

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<algorithm>

#include<iostream>

#include<cstring>

#include<cstdio>

#include<cmath>

#define LL long long

#define M 400020

using namespace std;

int read(){

	int nm=0,fh=1;char cw=getchar();

	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;

	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');

	return nm*fh;

}

int n,m,L,R,md,t[M],ans,p[M],t1,t2;

bool solve(int x){

	t1=0,t2=(n<<1);

	for(int i=1;i<=m;i++) p[i]=(t[i]>=x);

	for(int i=2;i<=n;i++) if(p[i]==p[i-1]) t1=i;

	for(int i=m-1;i>=n;i--) if(p[i]==p[i+1]) t2=i;

	if(t1==n||t2==n) return p[n]>0;

	if(t1>1&&t2<m&&p[t1]==p[t2]) return p[t1]>0;

	if(t2-n<n-t1) return p[t2]>0;

	if(t2-n>n-t1) return p[t1]>0;

	return (p[n]^(n&1)^1)>0;

}

int main(){

	n=read(),L=1,R=n,R<<=1,R--,m=R;

	for(int i=1;i<=n+n-1;i++) t[i]=read();

    while(L<=R){

    	md=(L+R>>1);

    	if(!solve(md)) R=md-1;

		else L=md+1,ans=md;

	}

	printf("%d\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.241897852086209x):
#include <cstdio>

#include <cctype>

#include <algorithm>

#define big(i, j) (a[i] >= x && a[j] >= x)

#define small(i, j) (a[i] < x && a[j] < x)

using namespace std;



int a[200005];

int n;



inline void in(register int &x){

	register char ch;

	x = 0;

	while(isspace(ch = getchar()));

	do x = x*10 + ch-'0'; while(isdigit(ch = getchar()));

}



bool check(int x){

	for(int i=1; i<n; i++){

		if(big(n-i, n-i+1) || big(n+i, n+i-1)) return true;

		if(small(n-i, n-i+1) || small(n+i, n+i-1)) return false;

	}

	return a[1] >= x;

}



int main(){

//	freopen("at2165.in", "r", stdin);

//	freopen("at2165.out", "w", stdout);

	in(n);

	for(int i=1; i<=n*2-1; i++)

		in(a[i]);

	int l = 1, r = n * 2 - 1, mid, ans;

	while(l <= r){

		mid = (l+r) >> 1;

		if(check(mid)){

//			printf("%d is valid.\n", mid);

			ans = mid;

			l = mid + 1;

		}

		else r = mid - 1;//, printf("%d is invaild.\n", mid);

	}

	printf("%d\n", ans);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int n,a[20000010];

bool x(int i,int j,int k) {

    return a[i]<=k&&a[j]<=k;

}

bool y(int i,int j,int k){

    return a[i]>k&&a[j]>k;

} 

bool check(int a){

    for(int i=0;i<n-1;i++){

        if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;

        if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;

    }

    return x(1,1,a);

}

int main(){

    scanf("%d",&n);

    for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);

    int l=1,r=2*n-1,mid;

    while(l<r){

	 	mid=(l+r)/2;

        if(check(mid)) r=mid;

        else l=mid+1;

    }

    printf("%d",l);

    return 0; 

}

// Faster C++ solution for the same problem (measured speedup: 5.165166330735814x):
//AT2165

#include <cstdio>



const int MAXN = (int)1e5;

int n, a[2*MAXN+5];



inline bool check(int x) {

	for (int i = 0; i < n-1; i++) {

		if ((a[n+i] <= x && a[n+i+1] <= x) || (a[n-i] <= x && a[n-i-1] <= x)) return true;

		if ((a[n+i] > x && a[n+i+1] > x) || (a[n-i] > x && a[n-i-1] > x)) return false;

	}

	return a[1] <= x;

}



int main() {

	scanf("%d", &n);

	for (register int i = 1; i < 2*n; i++)

		scanf("%d", a+i);

	int L = 0, R = 2*n-1;

	while (L < R) {

		int mid = (L+R)>>1;

		if (check(mid)) R = mid;

		else L = mid + 1;

	}

	printf("%d", L);

	return 0;

}