#C5294. Lonely Integers
Lonely Integers
Lonely Integers
You are given a sequence of N integers. Your task is to identify all the lonely integers in the sequence. An integer is called lonely if it appears exactly once in the sequence. If there are no lonely integers, output -1
. The result should be displayed in ascending order.
Example: For an input of 7
and the sequence 4 3 2 7 8 3 2
, the lonely integers are 4 7 8
.
inputFormat
The first line contains a single integer N representing the number of integers in the sequence.
The second line contains N space-separated integers.
outputFormat
If there exists at least one lonely integer, print them in ascending order separated by a single space. Otherwise, print -1
.
7
4 3 2 7 8 3 2
4 7 8