Problem:
Unique

For a sequence of integers $A = \{a_0, a_1, ..., a_{n-1}\}$ which is sorted by ascending order, eliminate all equivalent elements.

Input

A sequence is given in the following format.

$n$
$a_0 \; a_1 \; ,..., \; a_{n-1}$

Output

Print the sequence after eliminating equivalent elements in a line. Separate adjacency elements by a space character.

Constraints

$1 \leq n \leq 100,000$

$-1000,000,000 \leq a_i \leq 1,000,000,000$

$a_0 \leq a_1 \leq ... \leq a_{n-1}$

Sample Input 1

4
1 2 2 4

Sample Output 1

1 2 4

Solution in C (judge verdict: Accepted)

#include <stdio.h>

int unique(int [], int);
void pri(int [], int);

int main(void)
{
    int i, n, A[100000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);
    
    n = unique(A, n);
    pri(A, n);
    return 0;
}

int unique(int A[], int N)
{
    int i, j;

    for (i = 0, j = 1; j < N; j++)
        if (A[i] != A[j])
            A[++i] = A[j];
    return i + 1;
}

void pri(int A[], int N)
{
    int i;
    
    for (i = 0; i < N; i++) {
        if (i > 0) putchar(' ');
        printf("%d", A[i]);
    }
    putchar('\n');
}