#K11976. Special Elements in an Array

    ID: 23588 Type: Default 1000ms 256MiB

Special Elements in an Array

Special Elements in an Array

Given an array of integers, your task is to find all special elements in the array. A special element is defined as an element that appears strictly more than (\lfloor n/3 \rfloor) times, where (n) is the size of the array. Each special element should be output only once. For example, if the input array is [3, 2, 3, 5, 2, 2], since 2 appears 3 times which is more than (\lfloor6/3\rfloor = 2), it is considered a special element.

inputFormat

The first line contains a single integer (n) (the number of elements in the array). The second line contains (n) space-separated integers representing the elements of the array.

outputFormat

Print the special elements in non-decreasing order on a single line, separated by a space. If there are no special elements, print an empty line.## sample

6
3 2 3 5 2 2
2