JNext in SPOJ

Problem Statement
https://www.spoj.com/problems/JNEXT/

Please help me out to figure out why my solution is giving WA…??
Please provide any test case where my code wouldn’t work.

1
6
1 2 3 4 9 0
output should be 123904 but your output is 123940
try this
1
6
1 2 6 9 9 0
Maybe now you realised your mistake

Thanks mate.
I got my mistake.