#include <bits/stdc++.h>
using namespace std;
int n, cnt, top, b[200005];
int a[200005];
void do_it()
{
memset(b, 0, sizeof(b));
top = 0;
for (int i = 1; i <= n; i++)
{
if (a[i] != a[i - 1] && a[i] != 2 && a[i - 1] != 2)
{
b[top] = a[i];
top++;
a[i] = 2;
cnt--;
}
}
for (int i = 0; i < top; i++)
{
printf("%d ", b[i]);
}
scanf("\n");
if (!cnt)
{
return;
}
do_it();
return;
}
int main()
{
a[0] = 2;
scanf("%d", &n);
cnt = n;
for (int i = 1; i <= n; i++)
{
scanf("%d", a[i]);
}
do_it();
return 0;
}