P1059 [NOIP 2006 Junior] Mingming's Random Numbers

Description

Mingming wants to invite some classmates at school to fill out a questionnaire. For objectivity, he first uses a computer to generate $N$ random integers between $1$ and $1000$ ($N \leq 100$). For any duplicates, keep exactly one occurrence and remove the rest; different numbers correspond to different students' ID numbers. Then sort these numbers in ascending order, and visit the classmates in the sorted order. Please help Mingming remove duplicates and sort the numbers.

Input Format

The input has two lines. The first line contains a positive integer, the number $N$ of generated random integers. The second line contains $N$ positive integers separated by spaces, which are the generated random integers.

Output Format

The output also has two lines. The first line contains a positive integer $M$, the number of distinct random integers. The second line contains $M$ positive integers separated by spaces, which are the distinct random integers in ascending order.

Explanation/Hint

NOIP 2006 Junior, Problem 1. Translated by ChatGPT 5