#include
struct n
{
int num;
struct n *next;
};
struct n *f(int k)
{
struct n *p,*h,*t;
int i,num,j;
scanf("%d%d",&num);
for(j=1;j<=k;j++)
{p=(struct n *)malloc(sizeof(struct n));
p->num=num;
p->next=NULL;
if(h=NULL)
p=h;
else
{t->next=p;
t=p;}
scanf("%d%d",&num);
}
t->next=h;
return h;
}
struct n *v(struct n *h,int k)
{
struct n *q,*d;
int g=0,c=0;
q=h;
while(c!=k-1)
{q=q->next;d=q;
g++;
if(g==2)
{d->next=q->next;
q=q->next;
g=0;
c++;
}}
return q;
}
int main()
{
int k;
struct n *h,*q;
scanf("%d",&k);
h=f(k);
q=v(h,k);
printf("%d",q->num);
return 0;
}