Why test cases are getting failed in this code?
@Nitya_Somani
for test cases like
5
5 2 3 4 1
6
answer should be
1 and 5
2 and 4
not
5 and 1
2 and 4
correct that 
@Nitya_Somani
for test cases like
5
5 2 3 4 1
6
answer should be
1 and 5
2 and 4
not
5 and 1
2 and 4
correct that 