#C10331. Find Number With Triple Occurrence

    ID: 39525 Type: Default 1000ms 256MiB

Find Number With Triple Occurrence

Find Number With Triple Occurrence

You are given a list of positive integers. Your task is to determine whether any number appears at least three times. If such numbers exist, output the first one encountered when traversing the list from right to left; otherwise, output No.

In other words, let \(\textrm{count}(x)\) be the number of times \(x\) appears in the array. Find the element \(a_i\) (with the largest index \(i\)) such that \(\textrm{count}(a_i) \geq 3\). If no such element exists, print No.

inputFormat

The first line contains an integer \(N\) representing the number of elements. The second line contains \(N\) space-separated positive integers.

For example:

7
4 5 2 4 4 3 5

outputFormat

Output a single line containing the number which appears at least three times according to the specified condition, or No if no such number exists.

## sample
7
4 5 2 4 4 3 5
4