#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node*next;
}node;
node* createnode(int data)
{
    node* newnode=(node*)malloc(sizeof(node));
    if(!newnode)
    {
        printf("Invalid input");
        return NULL;
    }
    newnode->data=data;
    newnode->next=NULL;
    return newnode;
}
typedef struct
{
    node* top;
}stack;
void initstack(stack*s)
{
     s->top=NULL;
}
int isempty(stack*s)
{
    return s->top==NULL;
}
void push(stack*s,int data)
{
    node* newNode=createnode(data);
    if(!newNode) return;
    newNode->next=s->top;
    s->top=newNode;
}
int pop(stack*s)
{
    if(isempty(s)){
        printf("stack underflow");
        return -1;
    }
    int data=s->top->data;
    node* temp=s->top;
    s->top=s->top->next;
    free(temp);
    return data;
}
int isunique(int rolls[],int uniquerolls[],int n,int roll)
{
    for(int i=0;i<n;i++)
    {
        if(uniquerolls[i]==roll)
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    int N;
    if(scanf("%d",&N)!=1||N<=0)
    {
        printf("Invalid input");
        return 0;
    }
    int rolls[N];
    for(int i=0;i<N;i++)
    {
        scanf("%d",&rolls[i]);
    }
    int uniquerolls[N];
    int uniquecount=0;
    for(int i=0;i<N;i++)
    {
        if(isunique(uniquerolls,uniquecount,rolls[i]))
        {
            uniquerolls[uniquecount++]=rolls[i];
        }
    }
    stack s;
    initstack(&s);
    for(int i=0;i<uniquecount;i++)
    {
        push(&s,uniquerolls[i]);
    }
    while(!isempty(&s))
    {
        printf("%d\n",pop(&s));
    }
    
}