Runtime error coming up but answer is also printed

Kunal, plz see the order of input in question, firstly take n, then array values and then key, and use
int a[100000];, and then try to submit your code.

still showing error