Please remove the syntax errors only

thos is the code https://ide.codingblocks.com/s/347317

here

code is not showing desired output

https://ide.codingblocks.com/s/347968 this is the code

here
this prints your output

you still need to debug the code for case like
Input:
1 2 3 1 2 3 1 2 3 1 2 3 -1
Expected Output:
1 2 3
Your Output:
1

here is the corrected code