Given an array of elements. Your task is to find the second maximum element in the array.
The first line of input contains an integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains a single integer N which denotes the number of elements in the array. Second line of each test case contains N space separated integers which denotes the elements of the array.
For each test case in a new line print the second maximum element in the array. If there does not exist any second largest element, then print -1.
2 4 5 6 7
7 8 2 1 4 3
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.