Sum of the distance

Problem Name:
Sum of the distance
Site:HackerEarth
Links:
Tags:
Problem setters: