We'll call the consecutive distance rating of an integer sequence the sum of the distances between consecutive integers. Consider 2 9 3 6 8 1
.
2 9 3 6 8 1
<----5---->
<-2->
<--3-->
\$2\$ and \$1\$ are consecutive integers, and their distance apart in the sequence is \$5\$.
\$2\$ and \$3\$ are consecutive integers, and their distance apart in the sequence is \$2\$.
\$9\$ and \$8\$ are consecutive integers, and their distance apart in the sequence is \$3\$.
The consecutive distance rating is the sum of these distances: \$10\$.
Challenge
Given a possibly empty list of positive, unique integers, find its consecutive distance rating.
Format
You must accept a list of integers and output an integer in any reasonable format.
Rules
- Standard loopholes apply.
- This is code-golf, so the code with the fewest bytes (in each language) wins.
Test cases
[] -> 0
[33] -> 0
[65 57 78 32 81 19 50 24 85 3 97 43 10 73] -> 0
[1 2] -> 1
[2 1] -> 1
[1 2 3] -> 2
[1 3 2] -> 3
[31 63 53 56 96 62 73 25 54 55 64] -> 26
[54 64 52 39 36 98 32 87 95 12 40 79 41 13 53 35 48 42 33 75] -> 67
[94 66 18 57 58 54 93 53 19 16 55 22 51 8 67 20 17 56 21 59] -> 107
3 2 2
? \$\endgroup\$