http://www.codechef.com/viewsolution/5067179
Have a look at this code. It is the corrected version of your code. You are making a mistake in the part where min > a[0].
@roman28 thankyou