荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: westship (" "), 信区: ACMICPC
标  题: 5:Elevator
发信站: 荔园晨风BBS站 (Sat May 22 14:02:11 2004)

The highest building in our city has only one elevator. A request list is made
 up with N positive numbers. The numbers denote at which floors the elevator w
ill stop, in specified order. It costs 6 seconds to move the elevator up one f
loor, and 4 seconds to move down one floor. The elevator will stay for 5 secon
ds at each stop.

For a given request list, you are to compute the total time spent to fulfill t
he requests on the list. The elevator is on the 0th floor at the beginning and
 does not have to return to the ground floor when the requests are fulfilled.



Input

There are multiple test cases. Each case contains a positive integer N, follow
ed by N positive numbers. All the numbers in the input are less than 100. A te
st case with N = 0 denotes the end of input. This test case is not to be proce
ssed.


Output

Print the total time on a single line for each test case.


Sample Input

1 2
3 2 3 1
0


Sample Output

17
41


--



[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店