stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <iomanip>

#include <fstream>

#include <sstream>

#include <string>

#include <cmath>

#include <cstdio>

#include <cctype>

#include <ctime>

#include <cstdlib>

#include <cstring>

#include <cassert>

#include <cctype>

#include <cerrno>

#include <cfloat>

#include <ciso646>

#include <climits>

#include <clocale>

#include <complex>

#include <csetjmp>

#include <csignal>

#include <cstdarg>

#include <cstddef>

#include <cwchar>

#include <cwctype>

#include <exception>

#include <locale>

#include <numeric>

#include <new>

#include <stdexcept>

#include <limits>

#include <valarray>

#include <set>

#include <vector>

#include <stack>

#include <queue>

#include <deque>

#include <map>

#include <list>

#include <utility>

#include <bitset>

#include <algorithm>

#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)

#define MP make_pair

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;

const int INF = 1e9 + 7;



int n, per[200005];

bool rv[200005], alo[200005];



bool check(int num) 

{

	rep(i, n) rv[i] = per[i] > num;

	rep(i, n) alo[i] = (i == 0 || rv[i] != rv[i - 1]) && (i == n - 1 || rv[i] != rv[i + 1]);

	

	vector<int> vec;

	vec.push_back(1);

	for(int i = 1; i < n; i ++) if(alo[i] == alo[i - 1]) vec.back() ++;

	else {

		vec.back() *= alo[i - 1] ? -1 : 1;

		vec.push_back(1);

	}

	vec.back() *= alo[n - 1] ? -1 : 1;

	

	if(vec.size() == 1) {

		if(vec[0] < 0 && (n >> 1) & 1)

		rep(i, n) rv[i] ^= 1;

	} else {

		int pos = 0;

		rep(i, vec.size()) {

			if(vec[i] < 0) {

				bool ll = i == 0 ? rv[pos - vec[i]] : rv[pos - 1];

				bool rl = i == vec.size() - 1 ? rv[pos - 1] : rv[pos - vec[i]];

				rep(j, -vec[i]) rv[pos ++] = j < ((-vec[i]) >> 1) ? ll : rl;

			} else pos += vec[i];

		}

	}

	return rv[n >> 1];

}



int main()

{

	scanf("%d", &n);

	n = (n << 1) - 1;

	rep(i, n) scanf("%d", &per[i]);

	int l = 0, r = n;

	while(l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}

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

#include<cmath>

#include<algorithm>

#include<vector>

#include<cstring>

#define SF scanf

#define PF printf

#define MAXN 200010

using namespace std;

int n,m;

int a[MAXN],b[MAXN];

bool check(int x){

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

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

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

	}

	return b[1];

}

int main(){

	SF("%d",&n);

	m=2*n-1;

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

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

	int l=1,r=m,ans=m;

	while(l<=r){

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

		if(check(mid)){

			l=mid+1;

			ans=mid;

		}

		else

			r=mid-1;

	}

	PF("%d",ans);

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

#include<iostream>

#include<cmath>

#include<algorithm>

#include<string>

#include<cstring>

#include<cctype>

#include<queue>

#include<stack>

#include<map>

#include<set>

#include<iomanip>

#include<sstream>

#include<vector>

#include<cstdlib>

#include<ctime>

#include<list>

#include<deque>

#include<bitset>

#include<fstream>

#define ld double

#define ull unsigned long long

#define ll long long

#define pii pair<int,int >

#define iiii pair<int,pii >

#define mp make_pair

#define INF 1000000000

#define MOD 1000000007

#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)

inline int getint()

{

	int x=0,p=1;char c=getchar();

	while (c<=32)c=getchar();

	if(c==45)p=-p,c=getchar();

	while (c>32)x=x*10+c-48,c=getchar();

	return x*p;

}

using namespace std;

//purplesun

const int N=2e5+10;

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

//

int main()

{

	n=getint();

	rep(i,2*n-1)b[i]=getint();

	int lb=1,rb=2*n;

	while(rb-lb>1)

	{

		int mid=(lb+rb)>>1;

		rep(i,2*n-1)a[i]=(b[i]>=mid);

		int p=n-1,x=a[p],ans=0;

		bool flag=false;

		while(p>0)

		{

			p--;

			if(a[p]==x||a[n*2-p-2]==x)

			{

				ans=x;

				flag=true;

				break;

			}

			x^=1;

		}

		if(!flag)ans=a[0]&1;

		if(ans)lb=mid;

		else rb=mid;

	}

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

	return 0;

}


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

#include<cmath>

#include<algorithm>

#include<vector>

#include<cstring>

#define SF scanf

#define PF printf

#define MAXN 200010

using namespace std;

int n,m;

int a[MAXN],b[MAXN];

bool check(int x){

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

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

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

	}

	return b[1];

}

int main(){

	SF("%d",&n);

	m=2*n-1;

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

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

	int l=1,r=m,ans=m;

	while(l<=r){

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

		if(check(mid)){

			l=mid+1;

			ans=mid;

		}

		else

			r=mid-1;

	}

	PF("%d",ans);

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

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

#define per(i,a,b) for(int i=(a);i>=(b);i--)

#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])

using namespace std;

typedef long long i64;

typedef unsigned long long u64;

typedef unsigned u32;

typedef pair<int,int> pin;

#define mk(a,b) make_pair(a,b)

#define lowbit(x) ((x)&(-(x)))

#define sqr(a) ((a)*(a))

#define clr(a) (memset((a),0,sizeof(a)))

#define ls ((x)<<1)

#define rs (((x)<<1)|1)

#define mid (((l)+(r))>>1)

#define pb push_back

#define w1 first

#define w2 second

inline void read(int &x){

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

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

	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}

	x*=f;

}

inline void judge(){

	freopen("in.txt","r",stdin);

	freopen("out.txt","w",stdout);

}

/*******************************head*******************************/

const int maxn=200005;

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

inline bool check(int k){

	rep(i,1,2*n-1)b[i]=(a[i]>=k);

	int l=n,r=n;

	while(l>1&&b[l-1]!=b[l])l--;

	while(r<2*n-1&&b[r+1]!=b[r])r++;

	if(l==1&&r==2*n-1){

		return (n&1)?b[n]:(b[n]^1);

	}

	return n-l<r-n?b[l]:b[r];

}

int main(){

	//judge();

	read(n);rep(i,1,2*n-1)read(a[i]);

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

	while(l<=r){

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

		if(check(md)){

			ans=md;l=md+1;

		}else

			r=md-1;

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

	return 0;

}

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

#include<cmath>

#include<algorithm>

#include<vector>

#include<cstring>

#define SF scanf

#define PF printf

#define MAXN 200010

using namespace std;

int n,m;

int a[MAXN],b[MAXN];

bool check(int x){

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

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

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

	}

	return b[1];

}

int main(){

	SF("%d",&n);

	m=2*n-1;

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

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

	int l=1,r=m,ans=m;

	while(l<=r){

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

		if(check(mid)){

			l=mid+1;

			ans=mid;

		}

		else

			r=mid-1;

	}

	PF("%d",ans);

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

#include <map>

#include <cmath>

#include <queue>

#include <stack>

#include <vector>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



#define pb push_back

#define mp make_pair

#define fil(x,t) memset(x,t,sizeof(x));

#define siz(x) ((int)x.size())

#define rep(i,a,n) for (int i=(a);i<(n);++i)

#define per(i,a,n) for (int i=(n)-1;i>=(a);--i)

#define foreach(e,x) for (__typeof(x.begin()) e=x.begin();e!=x.end();++e)

typedef long long ll;

typedef double db;

typedef map<int,int> mii;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;



int read() {

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

  while (ch<'0'||ch>'9') f=(ch=='-')?-1:1,ch=getchar();

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

  return f*x;

}



//head



const int N=1e5+5;

const int MAX=2e5+5;



int n;

int a[MAX],t[MAX];



int check(int v){

  int lim=(n<<1)-1;

  rep (i,0,lim) t[i]=(a[i]>=v)?1:0;

  int l=0,r=lim-1;

  rep (i,n-1,lim-1) if(t[i]==t[i+1]) {

    r=i;break;

  }

  per (i,1,n) if(t[i]==t[i-1]) {

    l=i;break;

  }

  if (r==lim-1&&l==0) return t[0];

  if (n-l-1<=r-n+1) return t[l];

  else return t[r];

}

int main(){

  scanf("%d",&n);

  int lim=(n<<1)-1;

  rep (i,0,lim) a[i]=read();



  int low=0,high=lim,ans=0;

  while (low<=high) {

    int mid=(low+high)>>1;

    if(check(mid)) ans=mid,low=mid+1;

    else high=mid-1;

  }

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

  return 0;

}

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

#include<algorithm>

#define maxn 200005

using namespace std;

int n,l,r,a[maxn];

bool check(int x)

{

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

	{

		bool x1=0,x2=0;

		if(a[n-i]>=x&&a[n-i-1]>=x) x1=true;

		if(a[n+i]>=x&&a[n+i+1]>=x) x1=true;

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

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

		if(x1) return true;

		if(x2) return false;

	}

	return a[1]>=x;

}

int BS()

{

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

	while(l+1<r)

	{

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

		if(check(mid)) l=mid;

		else r=mid;

	}

	return l;

}

int main()

{

	scanf("%d",&n);

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

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

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

#include <iomanip>

#include <fstream>

#include <sstream>

#include <string>

#include <cmath>

#include <cstdio>

#include <cctype>

#include <ctime>

#include <cstdlib>

#include <cstring>

#include <cassert>

#include <cctype>

#include <cerrno>

#include <cfloat>

#include <ciso646>

#include <climits>

#include <clocale>

#include <complex>

#include <csetjmp>

#include <csignal>

#include <cstdarg>

#include <cstddef>

#include <cwchar>

#include <cwctype>

#include <exception>

#include <locale>

#include <numeric>

#include <new>

#include <stdexcept>

#include <limits>

#include <valarray>

#include <set>

#include <vector>

#include <stack>

#include <queue>

#include <deque>

#include <map>

#include <list>

#include <utility>

#include <bitset>

#include <algorithm>

#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)

#define MP make_pair

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;

const int INF = 1e9 + 7;



int n, per[200005];

bool rv[200005], alo[200005];



bool check(int num) 

{

	rep(i, n) rv[i] = per[i] > num;

	rep(i, n) alo[i] = (i == 0 || rv[i] != rv[i - 1]) && (i == n - 1 || rv[i] != rv[i + 1]);

	

	vector<int> vec;

	vec.push_back(1);

	for(int i = 1; i < n; i ++) if(alo[i] == alo[i - 1]) vec.back() ++;

	else {

		vec.back() *= alo[i - 1] ? -1 : 1;

		vec.push_back(1);

	}

	vec.back() *= alo[n - 1] ? -1 : 1;

	

	if(vec.size() == 1) {

		if(vec[0] < 0 && (n >> 1) & 1)

		rep(i, n) rv[i] ^= 1;

	} else {

		int pos = 0;

		rep(i, vec.size()) {

			if(vec[i] < 0) {

				bool ll = i == 0 ? rv[pos - vec[i]] : rv[pos - 1];

				bool rl = i == vec.size() - 1 ? rv[pos - 1] : rv[pos - vec[i]];

				rep(j, -vec[i]) rv[pos ++] = j < ((-vec[i]) >> 1) ? ll : rl;

			} else pos += vec[i];

		}

	}

	return rv[n >> 1];

}



int main()

{

	scanf("%d", &n);

	n = (n << 1) - 1;

	rep(i, n) scanf("%d", &per[i]);

	int l = 0, r = n;

	while(l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}

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

#include<algorithm>

#define maxn 200005

using namespace std;

int n,l,r,a[maxn];

bool check(int x)

{

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

	{

		bool x1=0,x2=0;

		if(a[n-i]>=x&&a[n-i-1]>=x) x1=true;

		if(a[n+i]>=x&&a[n+i+1]>=x) x1=true;

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

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

		if(x1) return true;

		if(x2) return false;

	}

	return a[1]>=x;

}

int BS()

{

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

	while(l+1<r)

	{

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

		if(check(mid)) l=mid;

		else r=mid;

	}

	return l;

}

int main()

{

	scanf("%d",&n);

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

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

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

#include<iostream>

#include<cmath>

#include<algorithm>

#include<string>

#include<cstring>

#include<cctype>

#include<queue>

#include<stack>

#include<map>

#include<set>

#include<iomanip>

#include<sstream>

#include<vector>

#include<cstdlib>

#include<ctime>

#include<list>

#include<deque>

#include<bitset>

#include<fstream>

#define ld double

#define ull unsigned long long

#define ll long long

#define pii pair<int,int >

#define iiii pair<int,pii >

#define mp make_pair

#define INF 1000000000

#define MOD 1000000007

#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)

inline int getint()

{

	int x=0,p=1;char c=getchar();

	while (c<=32)c=getchar();

	if(c==45)p=-p,c=getchar();

	while (c>32)x=x*10+c-48,c=getchar();

	return x*p;

}

using namespace std;

//purplesun

const int N=2e5+10;

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

//

int main()

{

	n=getint();

	rep(i,2*n-1)b[i]=getint();

	int lb=1,rb=2*n;

	while(rb-lb>1)

	{

		int mid=(lb+rb)>>1;

		rep(i,2*n-1)a[i]=(b[i]>=mid);

		int p=n-1,x=a[p],ans=0;

		bool flag=false;

		while(p>0)

		{

			p--;

			if(a[p]==x||a[n*2-p-2]==x)

			{

				ans=x;

				flag=true;

				break;

			}

			x^=1;

		}

		if(!flag)ans=a[0]&1;

		if(ans)lb=mid;

		else rb=mid;

	}

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

	return 0;

}


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

#include<algorithm>

#define maxn 200005

using namespace std;

int n,l,r,a[maxn];

bool check(int x)

{

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

	{

		bool x1=0,x2=0;

		if(a[n-i]>=x&&a[n-i-1]>=x) x1=true;

		if(a[n+i]>=x&&a[n+i+1]>=x) x1=true;

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

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

		if(x1) return true;

		if(x2) return false;

	}

	return a[1]>=x;

}

int BS()

{

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

	while(l+1<r)

	{

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

		if(check(mid)) l=mid;

		else r=mid;

	}

	return l;

}

int main()

{

	scanf("%d",&n);

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

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

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

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

#define per(i,a,b) for(int i=(a);i>=(b);i--)

#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])

using namespace std;

typedef long long i64;

typedef unsigned long long u64;

typedef unsigned u32;

typedef pair<int,int> pin;

#define mk(a,b) make_pair(a,b)

#define lowbit(x) ((x)&(-(x)))

#define sqr(a) ((a)*(a))

#define clr(a) (memset((a),0,sizeof(a)))

#define ls ((x)<<1)

#define rs (((x)<<1)|1)

#define mid (((l)+(r))>>1)

#define pb push_back

#define w1 first

#define w2 second

inline void read(int &x){

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

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

	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}

	x*=f;

}

inline void judge(){

	freopen("in.txt","r",stdin);

	freopen("out.txt","w",stdout);

}

/*******************************head*******************************/

const int maxn=200005;

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

inline bool check(int k){

	rep(i,1,2*n-1)b[i]=(a[i]>=k);

	int l=n,r=n;

	while(l>1&&b[l-1]!=b[l])l--;

	while(r<2*n-1&&b[r+1]!=b[r])r++;

	if(l==1&&r==2*n-1){

		return (n&1)?b[n]:(b[n]^1);

	}

	return n-l<r-n?b[l]:b[r];

}

int main(){

	//judge();

	read(n);rep(i,1,2*n-1)read(a[i]);

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

	while(l<=r){

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

		if(check(md)){

			ans=md;l=md+1;

		}else

			r=md-1;

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

	return 0;

}

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

#include<algorithm>

#define maxn 200005

using namespace std;

int n,l,r,a[maxn];

bool check(int x)

{

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

	{

		bool x1=0,x2=0;

		if(a[n-i]>=x&&a[n-i-1]>=x) x1=true;

		if(a[n+i]>=x&&a[n+i+1]>=x) x1=true;

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

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

		if(x1) return true;

		if(x2) return false;

	}

	return a[1]>=x;

}

int BS()

{

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

	while(l+1<r)

	{

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

		if(check(mid)) l=mid;

		else r=mid;

	}

	return l;

}

int main()

{

	scanf("%d",&n);

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

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

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

#include <map>

#include <cmath>

#include <queue>

#include <stack>

#include <vector>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



#define pb push_back

#define mp make_pair

#define fil(x,t) memset(x,t,sizeof(x));

#define siz(x) ((int)x.size())

#define rep(i,a,n) for (int i=(a);i<(n);++i)

#define per(i,a,n) for (int i=(n)-1;i>=(a);--i)

#define foreach(e,x) for (__typeof(x.begin()) e=x.begin();e!=x.end();++e)

typedef long long ll;

typedef double db;

typedef map<int,int> mii;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;



int read() {

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

  while (ch<'0'||ch>'9') f=(ch=='-')?-1:1,ch=getchar();

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

  return f*x;

}



//head



const int N=1e5+5;

const int MAX=2e5+5;



int n;

int a[MAX],t[MAX];



int check(int v){

  int lim=(n<<1)-1;

  rep (i,0,lim) t[i]=(a[i]>=v)?1:0;

  int l=0,r=lim-1;

  rep (i,n-1,lim-1) if(t[i]==t[i+1]) {

    r=i;break;

  }

  per (i,1,n) if(t[i]==t[i-1]) {

    l=i;break;

  }

  if (r==lim-1&&l==0) return t[0];

  if (n-l-1<=r-n+1) return t[l];

  else return t[r];

}

int main(){

  scanf("%d",&n);

  int lim=(n<<1)-1;

  rep (i,0,lim) a[i]=read();



  int low=0,high=lim,ans=0;

  while (low<=high) {

    int mid=(low+high)>>1;

    if(check(mid)) ans=mid,low=mid+1;

    else high=mid-1;

  }

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

  return 0;

}

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

using namespace std;

int N,A[200005],a[200005],l=1,r=200000,mid;

bool check(int n)

{

	int re=-1;

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

	if(A[i]>=n)

	a[i]=1;

	else

	a[i]=0;

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

	{

		if(a[N+i]==a[N+i-1])

		{

			re=a[N+i];

			break;

		}

		if(a[N-i]==a[N-i+1])

		{

			re=a[N-i];

			break;

		}

	}

	if(re!=-1)

	return re;

	else

	return a[1];

}

int main()

{

	scanf("%d",&N);

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

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

	while(l+1<r)

	{

		mid=(l+r)/2;

		if(check(mid))

		l=mid;

		else

		r=mid;

	}

	printf("%d",l);

	return 0;

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

#include <iomanip>

#include <fstream>

#include <sstream>

#include <string>

#include <cmath>

#include <cstdio>

#include <cctype>

#include <ctime>

#include <cstdlib>

#include <cstring>

#include <cassert>

#include <cctype>

#include <cerrno>

#include <cfloat>

#include <ciso646>

#include <climits>

#include <clocale>

#include <complex>

#include <csetjmp>

#include <csignal>

#include <cstdarg>

#include <cstddef>

#include <cwchar>

#include <cwctype>

#include <exception>

#include <locale>

#include <numeric>

#include <new>

#include <stdexcept>

#include <limits>

#include <valarray>

#include <set>

#include <vector>

#include <stack>

#include <queue>

#include <deque>

#include <map>

#include <list>

#include <utility>

#include <bitset>

#include <algorithm>

#include <functional>

#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)

#define MP make_pair

using namespace std;

typedef long long LL;

typedef pair<int, int> PII;

const int INF = 1e9 + 7;



int n, per[200005];

bool rv[200005], alo[200005];



bool check(int num) 

{

	rep(i, n) rv[i] = per[i] > num;

	rep(i, n) alo[i] = (i == 0 || rv[i] != rv[i - 1]) && (i == n - 1 || rv[i] != rv[i + 1]);

	

	vector<int> vec;

	vec.push_back(1);

	for(int i = 1; i < n; i ++) if(alo[i] == alo[i - 1]) vec.back() ++;

	else {

		vec.back() *= alo[i - 1] ? -1 : 1;

		vec.push_back(1);

	}

	vec.back() *= alo[n - 1] ? -1 : 1;

	

	if(vec.size() == 1) {

		if(vec[0] < 0 && (n >> 1) & 1)

		rep(i, n) rv[i] ^= 1;

	} else {

		int pos = 0;

		rep(i, vec.size()) {

			if(vec[i] < 0) {

				bool ll = i == 0 ? rv[pos - vec[i]] : rv[pos - 1];

				bool rl = i == vec.size() - 1 ? rv[pos - 1] : rv[pos - vec[i]];

				rep(j, -vec[i]) rv[pos ++] = j < ((-vec[i]) >> 1) ? ll : rl;

			} else pos += vec[i];

		}

	}

	return rv[n >> 1];

}



int main()

{

	scanf("%d", &n);

	n = (n << 1) - 1;

	rep(i, n) scanf("%d", &per[i]);

	int l = 0, r = n;

	while(l < r) {

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

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

		else r = mid;

	}

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

	return 0;

}

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

using namespace std;

int N,A[200005],a[200005],l=1,r=200000,mid;

bool check(int n)

{

	int re=-1;

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

	if(A[i]>=n)

	a[i]=1;

	else

	a[i]=0;

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

	{

		if(a[N+i]==a[N+i-1])

		{

			re=a[N+i];

			break;

		}

		if(a[N-i]==a[N-i+1])

		{

			re=a[N-i];

			break;

		}

	}

	if(re!=-1)

	return re;

	else

	return a[1];

}

int main()

{

	scanf("%d",&N);

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

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

	while(l+1<r)

	{

		mid=(l+r)/2;

		if(check(mid))

		l=mid;

		else

		r=mid;

	}

	printf("%d",l);

	return 0;

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

#include<iostream>

#include<cmath>

#include<algorithm>

#include<string>

#include<cstring>

#include<cctype>

#include<queue>

#include<stack>

#include<map>

#include<set>

#include<iomanip>

#include<sstream>

#include<vector>

#include<cstdlib>

#include<ctime>

#include<list>

#include<deque>

#include<bitset>

#include<fstream>

#define ld double

#define ull unsigned long long

#define ll long long

#define pii pair<int,int >

#define iiii pair<int,pii >

#define mp make_pair

#define INF 1000000000

#define MOD 1000000007

#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)

inline int getint()

{

	int x=0,p=1;char c=getchar();

	while (c<=32)c=getchar();

	if(c==45)p=-p,c=getchar();

	while (c>32)x=x*10+c-48,c=getchar();

	return x*p;

}

using namespace std;

//purplesun

const int N=2e5+10;

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

//

int main()

{

	n=getint();

	rep(i,2*n-1)b[i]=getint();

	int lb=1,rb=2*n;

	while(rb-lb>1)

	{

		int mid=(lb+rb)>>1;

		rep(i,2*n-1)a[i]=(b[i]>=mid);

		int p=n-1,x=a[p],ans=0;

		bool flag=false;

		while(p>0)

		{

			p--;

			if(a[p]==x||a[n*2-p-2]==x)

			{

				ans=x;

				flag=true;

				break;

			}

			x^=1;

		}

		if(!flag)ans=a[0]&1;

		if(ans)lb=mid;

		else rb=mid;

	}

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

	return 0;

}


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

using namespace std;

int N,A[200005],a[200005],l=1,r=200000,mid;

bool check(int n)

{

	int re=-1;

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

	if(A[i]>=n)

	a[i]=1;

	else

	a[i]=0;

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

	{

		if(a[N+i]==a[N+i-1])

		{

			re=a[N+i];

			break;

		}

		if(a[N-i]==a[N-i+1])

		{

			re=a[N-i];

			break;

		}

	}

	if(re!=-1)

	return re;

	else

	return a[1];

}

int main()

{

	scanf("%d",&N);

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

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

	while(l+1<r)

	{

		mid=(l+r)/2;

		if(check(mid))

		l=mid;

		else

		r=mid;

	}

	printf("%d",l);

	return 0;

}