getting SIGSEGV error

kindly help me to find out what is the run time error in this program CodeChef: Practical coding for everyone ??

That i because, you are taking input of numbers from 1 to n, but your input array heap is not extensible. I.e. you have declared heap too be of size just 10, so when the input no in your code is lets say 20, it’ll try accessing location heap[11], heap[12] etc, which are undefined as they are unallocated!!