calculate absolute difference in array