How do I speed up java solution to SPOJ HACKRNDM

spoj
tle

#1

problem link: http://www.spoj.com/problems/HACKRNDM/
and this is what I have tried: http://ideone.com/65qPOa

The problem has got only 19 successful submissions in java.


#2

Try making algorithmic changes. It would become easy once the element are sorted. After that you can run a binary search on ‘element+2’.