#C14594. Count Occurrences of Integers in a List

    ID: 44260 Type: Default 1000ms 256MiB

Count Occurrences of Integers in a List

Count Occurrences of Integers in a List

You are given a list of integers. Your task is to count the number of times each unique integer appears in the list. The result should be output as a dictionary (or map) formatted in the style of {key: value, ...} where each key is an integer from the list and value is its frequency.

Input Format: The input begins with an integer n representing the number of integers, followed by n space-separated integers.

Output Format: Output a single line containing the frequency dictionary. The keys in the dictionary must be sorted in ascending order. The dictionary should be printed in the following LaTeX format:

\(\{k_1: v_1, k_2: v_2, \ldots, k_m: v_m\}\)

For example, if the input is 7\n1 2 2 3 3 3 4, the output should be {1: 1, 2: 2, 3: 3, 4: 1}.

inputFormat

The first line of input contains an integer n (0 ≤ n ≤ 105), the number of integers. The second line contains n space-separated integers. Each integer can be negative, zero, or positive.

outputFormat

Output a single line representing the dictionary that maps each unique integer to the number of times it appears in the list. The keys in the dictionary must be printed in ascending order and formatted as {key: value, ...}.

## sample
7
1 2 2 3 3 3 4
{1: 1, 2: 2, 3: 3, 4: 1}