#C1050. Drone Delivery Total Distance
Drone Delivery Total Distance
Drone Delivery Total Distance
You are given the number of delivery destinations and their coordinates. Drones dispatch from a central hub (located at coordinate 0) and deliver packages to each destination, then return to the hub. The distance a drone travels for a single delivery is given by:
\(2 \times \text{coordinate}\)
Your task is to compute the total distance traveled by all drones to complete all deliveries.
Note: The input is read from standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line of input contains an integer n
, representing the number of delivery destinations. The following line contains n
space-separated integers, each representing the coordinate of a delivery destination.
For example:
3 2 5 8
outputFormat
Output a single integer, the total distance traveled by all drones.
For the sample input above, the output should be:
30## sample
3
2 5 8
30