stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:


#include<iostream>

#include<cstdio>

#include<cstring>

#include<set>

#include<algorithm>

#include<vector>

#include<queue>

#include<cmath>

#include<ctime>

#include<iomanip>

using namespace std;

int a[200008];

int e[200008];

int res[200008];

int n;

int check(int mid)

{

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

	{

		if(a[i]>=mid)e[i]=1;else e[i]=0;

	}

	int befi=0,beft=0;

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

	{

		if(e[i]==e[i+1])

		{

			if(befi==0)

			{

				for(int j=befi+1;j<=i+1;j++) res[j]=e[i];

			}

			else

			{

				if(e[i]==beft)

				{

					for(int j=befi+1;j<=i-1;j++) res[j]=e[i];

				}

				if(e[i]!=beft)

				{

					int brd=(befi+1+i-1)/2;

					for(int j=befi+1;j<=brd;j++) res[j]=beft;

					for(int j=brd+1;j<=i-1;j++) res[j]=e[i];

				}res[i]=res[i+1]=e[i+1];

			}

			befi=i+1,beft=e[i];

		}

	}

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

	{

		if(befi!=0)res[i]=beft;

		else res[i]=e[1];

	}

//	for(int i=1;i<=n;i++) cout<<mid<<"--"<<res[i]<<" ";cout<<"\n\n";

	return res[n/2+1];

}

int main()

{

	cin>>n;n=n*2-1;

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

	{

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

	}

	int l=1,r=n;int ans=0;

	while(l<=r)

	{

		int mid=(l+r)/2;

		if(check(mid))

		{

			l=mid+1;ans=mid;

		}

		else

		{

			r=mid-1;

		}

	}

	cout<<ans;

}


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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

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

#define ll long long

#define ull unsigned ll

#define uint unsigned

#define db long double

#define pii pair<int,int>

#define pll pair<ll,ll>

#define IT iterator

 

#define PB push_back

#define MK make_pair

#define LB lower_bound

#define UB upper_bound

#define EB emplace_back

#define fi first

#define se second

 

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)

#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)

#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)

#define CLR(a,v) memset(a,v,sizeof(a));

#define CPY(a,b) memcpy(a,b,sizeof(a));

 

#define LS3 k*2,l,mid

#define RS3 k*2+1,mid+1,r

#define LS5 k*2,l,mid,x,y

#define RS5 k*2+1,mid+1,r,x,y

#define GET pushdown(k);int mid=(l+r)/2

 

#define INF ((1ll<<60)-233)

#define sqr(x) ((x)*(x))

#define debug puts("wzpkking")

using namespace std;

int n,a[200005];

bool check(int mid){

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

		int s0=0,s1=0;

		if (a[n-i]>=mid&&a[n-i-1]>=mid) s1++;

		if (a[n-i]<mid&&a[n-i-1]<mid) s0++;

		if (a[n+i]>=mid&&a[n+i+1]>=mid) s1++;

		if (a[n+i]<mid&&a[n+i+1]<mid) s0++;

		if (s1) return 1;

		if (s0) return 0;

	}

	return a[1]>=mid;

}

int main(){

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

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

	scanf("%d",&n);

	For(i,1,2*n-1) scanf("%d",&a[i]);

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

	while (l<=r){

		int mid=(l+r)/2;

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

		else r=mid-1;

	}

	printf("%d",ans);

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

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

#include <cstring>

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <queue>

using namespace std;

#define ll long long

int n,m,w;

int a[500005];

int temp[500005];

bool check(int cm)

{

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

	{

		temp[i]=0;

		if(a[i]>cm)

		{

			temp[i]=1;

		}

	}

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

	{

		if(temp[n+i]==temp[n+i+1])

		{

			return temp[n+i];

		}

		else if(temp[n-i]==temp[n-i-1])

		{

			return temp[n-i];

		}

	}

	if(n%2==1)

	{

		return temp[n];

	}

	else

	{

		return 1-temp[n];

	}

}

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;

	while(l<r)

	{

		int mid=(l+r)/2;

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

		else r=mid;

	}

	printf("%d",l);

    return 0;

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

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

using namespace std;

const int maxn = 1e6 + 10;

int n, a[maxn + maxn];



int read() {

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

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

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

    return x * f;

}



bool check(int k) {

    bool tran[maxn]; // 相邻 

    for (int i = 1; i <= n; ++i) tran[i] = a[i] >= k;

    int mid = (n + 1) / 2, pos = 0, flg = -1;

    for (int i = mid; i < n; ++i) { if (tran[i] == tran[i + 1]) { pos = i - mid, flg = tran[i]; break; } }

    for (int i = mid; i > 1; --i) { if (tran[i] == tran[i - 1] && mid - i < pos) { flg = tran[i]; break; } } 

    if (flg != -1) return flg;

    return tran[1];

}



int main() {

    n = read(); n = n + n - 1;

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

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

    while (l <= r) {

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

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

        else r = mid - 1;

    }

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

    return 0;

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

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

using namespace std;

typedef long long ll;

const ll maxn=2e5;

ll n,m,w,a[maxn],b[maxn],d[maxn],c[maxn],k,depth;

bool check()

{

	int mid=(n+1)/2;

	if((b[mid]==1&&b[mid+1]==1)||(b[mid]==1&&b[mid-1]==1))return 1;

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

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

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

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

	}

	if(depth%2==1)return b[mid];

	else return (b[mid]^1);

}

int main(){

	ll r,l=1;

	scanf("%lld",&depth);n=depth*2-1;

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

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

	r=n;ll mid = l+r>>1;

	while(l <= r)

    {

    	mid=l+r>>1;

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

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

    		else b[i]=0;

        if(!check())

            r=mid-1; 

        else

            l=mid+1;

    }

    printf("%lld\n",l-1);

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

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

using namespace std;

const int N=1e6;

const int inf=1e9+10; 

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

int l,r,mid;

bool small(int x,int y,int q){

	return a[x]<=q && a[y]<=q;

}



bool big(int x,int y,int q){

	return a[x]>q && a[y]>q;

}



bool check(int x){

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

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

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

	}

	return a[1]<=x;

}

int main(){

	scanf("%d",&n);

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

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

	while(l<=r){

		mid=(l+r)/2;

		if(check(mid)){

			ans=mid;

			r=mid-1;

		}else l=mid+1;

	}

	printf("%d",ans);

	return 0;

}

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



const int MaxV = 200000;



int N, V;

int A[MaxV + 5];



void init() {

  scanf("%d", &N);

  V = 2 * N - 1;

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

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

}



inline int check(int mid) {

  static int b[MaxV + 5];

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

    if (A[i] >= mid) b[i] = 1;

    else b[i] = 0;

  static int pre[MaxV + 5], nxt[MaxV + 5];

  pre[1] = 1;

  for (int i = 2; i <= V; ++i)

    if (b[i] == b[i - 1]) pre[i] = pre[i - 1];

    else pre[i] = i;

  nxt[V] = V;

  for (int i = V - 1; i >= 1; --i)

    if (b[i] == b[i + 1]) nxt[i] = nxt[i + 1];

    else nxt[i] = i;

  if (pre[N] != N || nxt[N] != N) return b[N];

  int lpart = 0, rpart = V + 1;

  for (int i = 1; i < N; ++i) if (pre[i] != i) lpart = i;

  for (int i = V; i > N; --i) if (nxt[i] != i) rpart = i;

  if (lpart == 0 && rpart == V + 1) return b[1];

  else if (lpart == 0) return b[rpart];

  else if (rpart == V + 1) return b[lpart];

  else if (b[lpart] == b[rpart]) return b[lpart];

  else if (N - lpart < rpart - N) return b[lpart];

  else return b[rpart];

}



void solve() {

  int lbound = 1, rbound = V, ans = 0;

  while (lbound <= rbound) {

    int mid = (lbound + rbound) >> 1;

    if (check(mid) == 1) {

      ans = mid;

      lbound = mid + 1;

    } else rbound = mid - 1;

  }

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

}



int main() {

  init();

  solve();

  return 0;

}
// 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.1755327856734255x):
/*

#include<bits/stdc++.h>

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

#define ll long long

#define midl (l+r)>>1 

const int maxn=1e6+7;

using namespace std;

int n,l,r,mid,arc[maxn];

bool check(int pp)

{

	if (arc[n]<=pp&&arc[n+1]<=pp) return 1;

	if (arc[n]<=pp&&arc[n-1]<=pp) return 1;

	if (arc[n]>pp&&arc[n+1]>pp) return 0;

	if (arc[n]>pp&&arc[n-1]>pp) return 0;

	rep(i,1,n) 

	 {

	 	if (arc[n+i]<=pp&&arc[n+i+1]<=pp) return 1;

	    if (arc[n-i]<=pp&&arc[n-i-1]<=pp) return 1;

     	if (arc[n+i]>pp&&arc[n+i+1]>pp) return 0;

    	if (arc[n-i]>pp&&arc[n-i-1]>pp) return 0;

	 }

}

int main(){

	scanf("%d",&n);

	rep(i,1,(n<<1)-1) 

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

	for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1)//while(l<r) 

	 if (check(mid)==1) r=mid;

	 else l=mid+1;

	cout<<l;

	return 0;

}

*/

#include<stdio.h>

#define dn(i,j) (a[i]<=k && a[j]<=k)

#define up(i,j) (k<a[i] && k<a[j])



int a[200005],n,l,r,mid;



inline bool judge(const int &k)

{

    if (dn(n-1,n) || dn(n,n+1)) return 1;

    if (up(n-1,n) || up(n,n+1)) return 0;

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

    {

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

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

    }

    return dn(1,1);

}



int main()

{

    scanf("%d",&n);

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

    for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1) if (judge(mid)) r=mid;else l=mid+1;

    printf("%d",l);

}
// 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.162292470209527x):
/*

#include<bits/stdc++.h>

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

#define ll long long

#define midl (l+r)>>1 

const int maxn=1e6+7;

using namespace std;

int n,l,r,mid,arc[maxn];

bool check(int pp)

{

	if (arc[n]<=pp&&arc[n+1]<=pp) return 1;

	if (arc[n]<=pp&&arc[n-1]<=pp) return 1;

	if (arc[n]>pp&&arc[n+1]>pp) return 0;

	if (arc[n]>pp&&arc[n-1]>pp) return 0;

	rep(i,1,n) 

	 {

	 	if (arc[n+i]<=pp&&arc[n+i+1]<=pp) return 1;

	    if (arc[n-i]<=pp&&arc[n-i-1]<=pp) return 1;

     	if (arc[n+i]>pp&&arc[n+i+1]>pp) return 0;

    	if (arc[n-i]>pp&&arc[n-i-1]>pp) return 0;

	 }

}

int main(){

	scanf("%d",&n);

	rep(i,1,(n<<1)-1) 

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

	for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1)//while(l<r) 

	 if (check(mid)==1) r=mid;

	 else l=mid+1;

	cout<<l;

	return 0;

}

*/

#include<stdio.h>

#define dn(i,j) (a[i]<=k && a[j]<=k)

#define up(i,j) (k<a[i] && k<a[j])



int a[200005],n,l,r,mid;



inline bool judge(const int &k)

{

    if (dn(n-1,n) || dn(n,n+1)) return 1;

    if (up(n-1,n) || up(n,n+1)) return 0;

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

    {

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

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

    }

    return dn(1,1);

}



int main()

{

    scanf("%d",&n);

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

    for (r=(n<<1)-1,mid=l+r>>1;l<r;mid=l+r>>1) if (judge(mid)) r=mid;else l=mid+1;

    printf("%d",l);

}
// 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.156160358838289x):
#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);

}