How do I speed up java solution to SPOJ HACKRNDM

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.

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