Description
You have a list of integers and start counting from the first term to the next and continue from that to the next and so on..
How many times have you counted?
For example given [ 2, 5, 3, 8 ]
you start at 2 and count to 5 -> 3 4 5 (3 times)
then from 5.. 4 3 (2 times)
and finally 4 5 6 7 8 (5 times)
You counted 10 times.
With ragged lists, when you have a sublist just count the sublist and use that result.
for example [ 1, [ 3, 6 ] ]
1 to ( count[ 3, 6 ] ->3 )
1 to 3 -> 2
For empty lists you count 0 times, the same applies for lists of one element or lists of equal elements.
[ ] -> 0
[ 99 ] -> 0
[ 8, 8, 8 ] -> 0
Task
Given a ragged list of non negative integers count it as described above.
Test cases
[] -> 0
[[2,5]] -> 0
[99] -> 0
[8,8,8] -> 0
[1,1] -> 0
[0,9] -> 9
[2,5,3,8] -> 10
[1,[3,6]] -> 2
[[],4,[[5,3],2]] -> 8
[100,100,[7,[[[6]]]],[[4,8]]] -> 100
[[9,5],0] -> 4
[[],[]] -> 0
[[],3,[]] -> 6
[1,[2,5,10]] -> 7
[2,6,9] -> 7
[[1,2],[1,3],[1,4]] -> 2
[1,99] -> 98
[11,9,6] -> 5
[0,1,2,3,4] -> 4
[2,3,3,3,2] -> 2
[0,1,0,1] -> 3
This is code-golf, all usual golfing rules apply.