See also my comments to the question.
Looks like you missed a small detail in your task description.
There, the difference is defined as
|arr[i]-arr[j]|
But you are calculating the difference simply as
arr[j] - arr[i]
Conclution
Use
Math.abs(value)
to solve the problem.
For more information about
Math.abs()
see e.g. here:
Java - abs() Method[
^]
I hope it helps.