What is wrong in my code?

I’m a newbie here. Please take a look at my code here
and tell why its wrong. Its showing wrong answer, ive checked using default input and am getting correct output. SO please help

my approach: after taking input i tried to check if X is present in array or not(if no then i output -1 as said). if yes then i counted no of element in array less than X into variable count. And displayed no of operation needed using variable count and p.