sum of absolute difference of an array
using System;
public class Hello
{
public static void Main()
{
var arr = new int[]{10, 11, 7, 12, 14};
Console.WriteLine(findTotalDistance(5,arr));
}
public static int findTotalDistance(int input1 , int[] input2)
{
var sum = 0;
for (var i=1; i<input1; i++)
sum+=Math.Abs(input2[i-1]-input2[i]);
return sum;
}
}