#P1897. 电梯里的尴尬
电梯里的尴尬
Description
So, while trying to strike up a conversation with the “da shen,” Xiao W also watches the floor number displayed in the elevator. He notices that going up one floor takes seconds, going down one floor takes seconds, each door opening takes seconds (only if someone arrives and the elevator stops), and each person getting off adds second.
It is specifically stated that the elevator starts on floor , and it must return to floor at the end for the trip to be considered finished. Assuming that at the beginning we know the destination floor of every person currently inside the elevator, can you compute the total time needed to complete this trip?
This is a very simple problem. You should know that Xiao W has already trained himself to quickly do the mental arithmetic. Now you try to program it!
Input Format
There are lines.
The first line contains a positive integer , the number of people riding the elevator.
The second line contains positive integers. denotes the destination floor of the -th person.
Output Format
Output one line containing a positive integer — the time needed to complete this trip.
4
2 4 3 2
59
Hint
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号