Publicis SapientOA #1
Get Minimum Time
估计中等可在线判题
Carry the boxes of each floor to the top floor with separate round trips from that floor; each box requires one round trip plus 1 minute of loading and unloading.
The standard input/output format and supplementary bounds of this site are as stated in this problem.
输入格式
The first line contains n (1≤n≤10^5); the second line contains n non-negative integers boxes[i] (≤10^9), where index i corresponds to floor i and the top floor is n.
输出格式
Output the minimum total number of minutes (the integer may exceed 32 bits).
样例 1
输入:
4
2 1 0 1
输出:
28
样例 2
输入:
1
0
输出:
0
样例 3
输入:
3
0 0 2
输出:
6