#K50632. Organize Stamps

    ID: 28908 Type: Default 1000ms 256MiB

Organize Stamps

Organize Stamps

You are given a collection of stamps, each with a given rarity level. Your task is to sort the stamps by their rarity levels in non-decreasing order and determine the number of unique rarity levels.

Formally, you are given an integer \( n \) and a sequence of \( n \) integers \( a_1, a_2, \dots, a_n \) representing the rarity levels. You need to output:

  • The number of unique rarity levels.
  • The list of rarity levels sorted in non-decreasing order.

For example, if \( n=5 \) and the stamps are [4, 2, 3, 2, 4], then the number of unique rarity levels is \(3\) and the sorted order is [2, 2, 3, 4, 4].

inputFormat

The first line contains an integer \( n \) (the number of stamps).
The second line contains \( n \) space-separated integers representing the rarity levels of the stamps.

outputFormat

Output two lines:
The first line should contain the number of unique rarity levels.
The second line should contain the sorted list of rarity levels separated by spaces.

## sample
5
4 2 3 2 4
3

2 2 3 4 4

</p>