#C12901. Most Frequent Element Finder

    ID: 42380 Type: Default 1000ms 256MiB

Most Frequent Element Finder

Most Frequent Element Finder

You are given an array of integers. Your task is to determine the integer that occurs most frequently in the array and its frequency. In case of a tie (i.e. multiple values having the same maximum frequency), choose the smallest integer among them.

Formally, let \( A = [a_1, a_2, \dots, a_n] \) be the input array. You need to compute the value \( x \) and its frequency \( f \) such that:

[ f = \max_{y \in A} #{i : a_i = y} ]

and if there exists more than one \( y \) with the same frequency \( f \), then choose the smallest such \( y \) (i.e., \( x = \min\{ y : \#\{i : a_i = y\} = f\} \)).

If the input array is empty, output None 0 (without quotes).

inputFormat

The first line contains an integer n which denotes the number of elements in the array. The second line contains n space-separated integers representing the elements of the array. If n is 0, there will be no second line.

outputFormat

Print two space-separated values: the integer that occurs most frequently and its frequency. If the array is empty, print None 0.

## sample
6
1 3 1 3 2 1
1 3