#C14265. Second Smallest and Second Largest
Second Smallest and Second Largest
Second Smallest and Second Largest
Given an array of distinct integers with at least two elements, your task is to find the second smallest and the second largest elements in the array.
The input will start with an integer \( n \) (\( n \ge 2 \)), representing the number of elements in the array. The following line contains \( n \) space-separated integers.
Output the second smallest and second largest numbers separated by a single space. If the array contains less than two elements, the program should report an error.
Note: The problem guarantees that all the integers in the array are distinct.
inputFormat
The first line of input contains a single integer \( n \) (where \( n \ge 2 \)). The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Print two integers separated by a space: the second smallest and the second largest elements in the array.
## sample6
8 3 1 7 6 4
3 7