Getting WA please help Question STICKS

link to question https://www.codechef.com/problems/STICKS
here is my code .
I have put comment lines which indicated the purpose
and and since am a beginner here my Time limit is a lot but i will optimise it more but here am getting WA which i am unable to understand.
link to solution.
https://www.codechef.com/viewsolution/29070741

Consider the test case
1
6
3 3 2 2 3 3
Your code outputs 6.
The second largest need not be lesser than than the largest.

1 Like

thanks a ton @everule1 means a lot.

1 Like

@everule1 i then submitted with after sorting and got AC
but then i found max two times but i was getting runtime error i dont why
https://www.codechef.com/viewsolution/29088480

Sigsegv, sigfpe?

Sigsegv
i think to do something with around line 79 .
getting sigsegv while submitting and for sample test case getting SIGTSTP