You are given an array A of size N. The array contains almost distinct elements with some duplicated. You have to print the elements in sorted order which appears more than once.
The first line of input contains T, denoting the number of testcases. T testcases follow. Each testcase contains two lines of input. The first line of input contains size of array N. The second line contains N integers separated by spaces.
For each test case, in a new line, print the required answer. If there are no duplicates print -1.
Your task is to complete the function SortedDuplicates(arr, n) which accepts array and its size as an argument.
1 <= T <= 100
1 <= N <= 100
1 <= Ai <= 106
3 4 5 7 8 1 2 1 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.