#C9370. Second Smallest Element Finder
Second Smallest Element Finder
Second Smallest Element Finder
You are given an array of \(N\) integers. Your task is to find the second smallest distinct element in the array. In other words, considering only unique values in the array sorted in ascending order \((a_1, a_2, \ldots, a_k)\), you are to output \(a_2\) if it exists. If no such element exists (i.e. all values in the array are equal or the array contains fewer than two elements), output \(-1\).
Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line contains an integer (N) (the number of elements in the array). The second line contains (N) space-separated integers representing the elements of the array.
outputFormat
Output the second smallest distinct element in the array. If it does not exist, print (-1).## sample
6
23 45 12 34 25 12
23