#include<iostream>
#include<vector>
using namespace std;
int main()
{
int n,m,sum;
vector<int> v;
while (cin >> n)
{
if (n == 0)
break;
while (n--&&cin >> m)
{
v.push_back(m);
}
sum = 6*v[0];
for (int i = 1; i <= v.size() - 1; ++i)
{
if (v[i]>v[i-1])
sum = sum + 6 * (v[i]-v[i-1]);
else sum = sum + 4 * (v[i - 1] - v[i]);
}
sum = sum + 5 * v.size();
cout << sum << endl;
v.clear();
}
return 0;
}
1008 Elevator
最新推荐文章于 2022-03-10 11:01:42 发布