1 testcase not working

https://ide.codingblocks.com/s/280225 pls check 1 testcase not working

Consider a case:
7
1 2 3 1 2 4 1
2 1 3 1 5 1 1

Your o/p
[1, 1, 1, 3]

Expected o/p
[1, 1, 1, 2, 3]