100 atcoder#ABC160C. [ABC160C] Traveling Salesman around Lake
[ABC160C] Traveling Salesman around Lake
Score : points
Problem Statement
There is a circular pond with a perimeter of meters, and houses around them.
The -th house is built at a distance of meters from the northmost point of the pond, measured clockwise around the pond.
When traveling between these houses, you can only go around the pond.
Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the houses.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum distance that needs to be traveled when you start at one of the houses and visit all the houses.
20 3
5 10 15
10
If you start at the -st house and go to the -nd and -rd houses in this order, the total distance traveled will be .
20 3
0 5 15
10
If you start at the -nd house and go to the -st and -rd houses in this order, the total distance traveled will be .