Exam Invigilator
GIHS has an upcoming practice exam session for its year 12 students. Mr Longbottom has been appointed as the only exam invigilator for the competitive programming mid-year examination.
Mr Longbottom expects that some of the students will cheat and collude together if given the opportunity, so he will try his best to stop this.
Unusually, the exam is setup so that all students taking the competitive programming class are arranged in a single line. However, the position
of the students are not uniformly distributed.
In an effort to stop cheating, Mr Longbottom will position himself between the two students who are closest together in the exam hall.
Input
The first line contains one integer
, representing the number of students.
The next line contains integers, the position of each student
. Every position
is unique.
Output
Output the two student positions that Mr Longbottom should stand between to reduce the chance of cheating.
Ensure that the two positions are seperated by a space and the smaller position come before the larger position.
If there are multiple pairs of students that are seperated by the minimum distance, return the pair which contains the smallest seat position. In other words, in the exam hall, if there are multiple equal minimum distances, display the pair closests to seat position 0.
Example
Input 1
4
6 2 4 1
Output 1
1 2

- Students at positions 1 and 2 are a distance of 1 apart.
- Students at positions 2 and 4 are a distance of 2 apart.
- Students at positions 4 and 6 are a distance of 2 apart.
Therefore, return the first pair as they are only 1 apart.
Input 2
6
0 15 10 12 4 17
Output 2
10 12
Although 15 and 17 are also 2 units apart, 10 and 12 are the pair who appear closest to seat position 0.
Input 3
2
10 0
Output 3
0 10
Comments