#K14286. Minimum Signal Propagation Time
Minimum Signal Propagation Time
Minimum Signal Propagation Time
You are given a village with N houses arranged in a row. The position of each house is given by an integer. When a signal is sent from one house, it takes time equal to the distance (i.e. the absolute difference in position) for the signal to reach another house. Since every house sends a signal simultaneously, the minimum time required for every house to receive a signal from every other house is determined by the two houses that are farthest apart.
In other words, if the positions are given by an array positions
, the answer is given by
$$\max(positions)-\min(positions)$$
Your task is to compute and output this minimum required time.
inputFormat
The input is given via stdin and consists of two lines:
- The first line contains a single integer
N
— the number of houses. - The second line contains
N
space-separated integers, representing the positions of the houses.
outputFormat
The output should be a single integer printed to stdout — the minimum time required for every house to receive signals from every other house.
## sample4
1 3 6 7
6