Console Output for following code:
Input : [1, 4, 9, 8, 7, 5, 4]
Output: [4, 9, -1, -1, -1, -1, -1]
Input : [4, 3, 7, 2, 9, 1, 8]
Output: [7, 7, 9, 9, -1, 8, -1]
Input : [4, 4, 5, 2, 6, 6, 1]
Output: [5, 5, 6, 6, -1, -1, -1]
Process finished with exit code 0