#include<iostream>
using namespace std;
struct Node
{
    int data;
    Node* next;
    Node(int x):data(x),next(nullptr){};
};
Node* back(Node* node,int& m)
{
    if(node==NULL)return NULL;
    Node* before=back(node->next,m);
    if(--m==0)return node;//结束
    else return before;//回溯
}
int main()
{
    int n,m,x;
    while(cin>>n)
    {
        Node* p=new Node(0);
        Node* h=p;
        while(n--)
        {
            cin>>x;
            p->next=new Node(x);
            p=p->next;
        }
        cin>>m;
        Node* rec=back(h->next,m);
        if(rec!=NULL)
            cout<<rec->data<<endl;
        else
            cout<<"0"<<endl;
    }
}