Scanning the $N$ integers left to right, collapse each run of consecutive equal values into a single copy. Print the remaining integers in order, space-separated.
Input
Line 1: $N$ ($1 \le N \le 1000$). Line 2: $N$ integers in $[-10000, 10000]$.
Output
Print the sequence with consecutive duplicates removed.
Example 1
Input
8 1 2 2 3 3 3 4 2
Output
1 2 3 4 2
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.