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

#define N 500005

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';

	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();

	x=w?-x:x;

}



int l,r;

int n,m;

int a[N],b[N];



bool ok(int x){

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

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

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

		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;

		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;

	}

	return b[1];

}

signed main(){

	rd(n);m=n*2-1;l=1;r=m+1;

	for(int i=1;i<=m;i++) rd(a[i]);

	while(l<r){

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

		ok(mid) ? l=mid+1 : r=mid;

	}

	cout<<l-1<<endl;

}


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

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re 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 false;

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

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

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

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

    }

    

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

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

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



using namespace std; 

int N,a[200001];

bool b[200001];

bool check(int x)

{ 	

		for(int i=1;i<=(N<<1)-1;++i)b[i]=(a[i]<=x); 

		for(int i=0;i<N;++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];

		} 

		return b[1]; 

} 



int main(){ 

	 scanf("%d",&N);

	 for(int i=1;i<=(N<<1)-1;++i)

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

		int l=1,r=(N<<1)-1,m;

	while(l<r)

	   if(check(m=l+r>>1))r=m;

	   else 

	   	l=m+1; 

	   	printf("%d",l); 

}


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

#include <algorithm>

#include <cstring>



#define re register int



using namespace std;



const int maxn=200010;



int n;

int a[200100];



inline bool check(int x){

    for(re 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 false;

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

            return true;

    }

    return a[(n<<1)-1]>=x;

}

int main(){

    scanf("%d",&n);

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

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

    }

    

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

    

    while(l<=r){

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

        if(check(mid))

            l=mid+1,ans=mid;

        else

            r=mid-1;

    }

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

    return 0;

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

using namespace std;



const int N=200010;

int n,a[N];

bool f[N];



bool check(int x)

{

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

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

	{

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

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

	}

	return f[1];

}



int main()

{

	scanf("%d",&n);

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

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

	while(l<r)

	{

		mid=(l+r)/2;

		if(check(mid)) l=mid+1;

		else r=mid-1;

	}

	printf("%d\n",check(l)?l:l-1);

	return 0;

}

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

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

	scanf("%d",&n);

	for(int i=1;i<n<<1;i++)scanf("%d",a+i);

	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.209845824432589x):
#include<cstdio>

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

    scanf("%d",&n);

    for(int i=1;i<n<<1;i++)scanf("%d",a+i);

    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.209845824432589x):
#include<cstdio>

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int n,a[200010];



template <typename T> inline void read(T &a) {

	a = 0;char c = getchar();int f = 1;

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

	while(isdigit(c)) {a = (a<<3) + (a<<1) + (c ^ 48); c = getchar();}

	a*=f;

}



inline bool check (int k) {

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

		return true;

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

		return false;

	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 true;

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

			return false;

	}

	return a[1] <= k;

}



int main () {

	read(n);

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

		read(a[i]);

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

	while (l < r) {

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

		if(check(mid)) r = mid;

		else l = mid + 1;

	}

	cout<<l<<endl;

	return 0;

}

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

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<bits/stdc++.h>

#define N 500005

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';

	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();

	x=w?-x:x;

}



int l,r;

int n,m;

int a[N],b[N];



bool ok(int x){

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

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

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

		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;

		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;

	}

	return b[1];

}

signed main(){

	rd(n);m=n*2-1;l=1;r=m+1;

	for(int i=1;i<=m;i++) rd(a[i]);

	while(l<r){

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

		ok(mid) ? l=mid+1 : r=mid;

	}

	cout<<l-1<<endl;

}


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

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std; 

int N,a[200001];

bool b[200001];

bool check(int x)

{ 	

		for(int i=1;i<=(N<<1)-1;++i)b[i]=(a[i]<=x); 

		for(int i=0;i<N;++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];

		} 

		return b[1]; 

} 



int main(){ 

	 scanf("%d",&N);

	 for(int i=1;i<=(N<<1)-1;++i)

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

		int l=1,r=(N<<1)-1,m;

	while(l<r)

	   if(check(m=l+r>>1))r=m;

	   else 

	   	l=m+1; 

	   	printf("%d",l); 

}


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

int n,m,i,l,r,a[1<<21];int f(){for(i=1;i<n;i++){if(a[n+i-1]>m==a[n+i]>m)return a[n+i]>m;if(a[n-i+1]>m==a[n-i]>m)return a[n-i]>m;}return a[1]>m;}main(){scanf("%d",&n);for(i=1;i<n+n;i++)scanf("%d",a+i);for(l=1,r=n+n-1;l<=r?1:!printf("%d",l);f()?l=m+1:r=m-1)m=(l+r)/2;}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



const int N=200010;

int n,a[N];

bool f[N];



bool check(int x)

{

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

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

	{

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

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

	}

	return f[1];

}



int main()

{

	scanf("%d",&n);

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

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

	while(l<r)

	{

		mid=(l+r)/2;

		if(check(mid)) l=mid+1;

		else r=mid-1;

	}

	printf("%d\n",check(l)?l:l-1);

	return 0;

}

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

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

	scanf("%d",&n);

	for(int i=1;i<n<<1;i++)scanf("%d",a+i);

	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.186264287286106x):
#include<cstdio>

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

    scanf("%d",&n);

    for(int i=1;i<n<<1;i++)scanf("%d",a+i);

    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.186264287286106x):
#include<cstdio>

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

using namespace std;



int n,a[200010];



template <typename T> inline void read(T &a) {

	a = 0;char c = getchar();int f = 1;

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

	while(isdigit(c)) {a = (a<<3) + (a<<1) + (c ^ 48); c = getchar();}

	a*=f;

}



inline bool check (int k) {

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

		return true;

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

		return false;

	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 true;

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

			return false;

	}

	return a[1] <= k;

}



int main () {

	read(n);

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

		read(a[i]);

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

	while (l < r) {

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

		if(check(mid)) r = mid;

		else l = mid + 1;

	}

	cout<<l<<endl;

	return 0;

}

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

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

#define N 500005

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';

	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();

	x=w?-x:x;

}



int l,r;

int n,m;

int a[N],b[N];



bool ok(int x){

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

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

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

		if((b[n-i] and b[n-i-1]) or (b[n+i] and b[n+i+1])) return 1;

		if((!b[n-i] and !b[n-i-1]) or (!b[n+i] and !b[n+i+1])) return 0;

	}

	return b[1];

}

signed main(){

	rd(n);m=n*2-1;l=1;r=m+1;

	for(int i=1;i<=m;i++) rd(a[i]);

	while(l<r){

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

		ok(mid) ? l=mid+1 : r=mid;

	}

	cout<<l-1<<endl;

}


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

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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



using namespace std; 

int N,a[200001];

bool b[200001];

bool check(int x)

{ 	

		for(int i=1;i<=(N<<1)-1;++i)b[i]=(a[i]<=x); 

		for(int i=0;i<N;++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];

		} 

		return b[1]; 

} 



int main(){ 

	 scanf("%d",&N);

	 for(int i=1;i<=(N<<1)-1;++i)

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

		int l=1,r=(N<<1)-1,m;

	while(l<r)

	   if(check(m=l+r>>1))r=m;

	   else 

	   	l=m+1; 

	   	printf("%d",l); 

}


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

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

#include<cmath>

#include<stack>

#include<queue>

#include<cstdio>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

template<class Read>void in(Read &x){

    x=0;

    int f=0;

    char ch=getchar();

    while(ch<'0'||ch>'9'){

        f|=(ch=='-');

        ch=getchar();

    }

    while(ch>='0'&&ch<='9'){

        x=(x<<1)+(x<<3)+(ch^48);

        ch=getchar();

    }

    x=f?-x:x;

    return;

}

int n,a[200005],l=1,r=(n*2-1),ans;

bool check(int x){

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

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

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

	}

	if(a[1]>x)return 0;

	else return 1;

}

int main(){

	in(n);

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

	r=n*2-1;

	while(l<=r){

		int mid=(l+r)/2;

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

		else l=mid+1;

	}

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

	return 0;

}

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

#include<algorithm>

int t,n;

int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;

inline int top()

{

	register int i,ii;

	if(b[0]==b[1]||b[0]==b[-1])return b[0];

	for(i=1,ii=-1;i<t;i++,ii--)

	{

		if(b[i+1]==b[i])goto T;

		if(b[ii-1]==b[ii])goto S;

	}return(t&1)^b[0];

	T:return b[i];

	S:return b[ii];

}

inline int valid(int mid)

{

	register int i;

	for(i=-t;i<=t;i++)

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

	return top();

}

int main()

{

	scanf("%d",&n);

	register int i,ii;

	t=n-1;

	for(i=-t;i<=t;i++)

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

	int l=1,r=2e9;

	while(l+1<r)

	{

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

		if(valid(mid))l=mid;

		else r=mid;

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

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

using namespace std;



const int N=200010;

int n,a[N];

bool f[N];



bool check(int x)

{

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

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

	{

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

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

	}

	return f[1];

}



int main()

{

	scanf("%d",&n);

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

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

	while(l<r)

	{

		mid=(l+r)/2;

		if(check(mid)) l=mid+1;

		else r=mid-1;

	}

	printf("%d\n",check(l)?l:l-1);

	return 0;

}

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



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

		if (!check(mid)) l = mid + 1;

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (int i = 0; i < n; ++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];

	}

	return b[1];

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

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

	scanf("%d",&n);

	for(int i=1;i<n<<1;i++)scanf("%d",a+i);

	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.188556827092143x):
#include <stdio.h>



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

		if (!check(mid)) l = mid + 1;

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (int i = 0; i < n; ++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];

	}

	return b[1];

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

#include<cstdio>

using namespace std;



int n,a[200005];



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(){

    scanf("%d",&n);

    for(int i=1;i<n<<1;i++)scanf("%d",a+i);

    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.188556827092143x):
#include <stdio.h>



const int N = 1e5;



int n;

int a[N << 1 | 1], b[N << 1 | 1];



bool check(int t);



int main() {

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

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

	scanf("%d", &n);

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

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

	while (l < r) {

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

		if (!check(mid)) l = mid + 1;

		else r = mid;

	}

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

	return 0;

}



bool check(int t) {

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

	for (int i = 0; i < n; ++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];

	}

	return b[1];

}