#include<stdio.h>
#include<stdlib.h>
int a[10000],b[3500];
int cmp(const void *a,const void *b)
{
return *(int *)b-*(int *)a;
}
int main()
{
int n,t,i,k;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(k=0,i=0;i<n;i+=6)
{
t=a[i]>a[i+1]?a[i]:a[i+1];
t=t>a[i+2]?t:a[i+2];
b[k++]=t;
}
for(i=3;i<n;i+=6)
{
t=a[i]<a[i+1]?a[i]:a[i+1];
t=t<a[i+2]?t:a[i+2];
b[k++]=t;
}
qsort(b,k,sizeof(b[0]),cmp);
printf("%d\n",b[0]);
}
return 0;
}
#include<stdlib.h>
int a[10000],b[3500];
int cmp(const void *a,const void *b)
{
return *(int *)b-*(int *)a;
}
int main()
{
int n,t,i,k;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(k=0,i=0;i<n;i+=6)
{
t=a[i]>a[i+1]?a[i]:a[i+1];
t=t>a[i+2]?t:a[i+2];
b[k++]=t;
}
for(i=3;i<n;i+=6)
{
t=a[i]<a[i+1]?a[i]:a[i+1];
t=t<a[i+2]?t:a[i+2];
b[k++]=t;
}
qsort(b,k,sizeof(b[0]),cmp);
printf("%d\n",b[0]);
}
return 0;
}