hdu1008Elevator
http://acm.hdu.edu.cn/showproblem.php?pid=1008
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int n;
int a;
while(cin>>n)
{
if(n>0)
{
int i=0;
int s=0;
while(n--)
{
cin>>a;
if(i<a)
{
s+=6*(a-i);
s+=5;
i=a;
}
else
{
s+=4*(i-a);
s+=5;
i=a;
}
}
cout<<s<<endl;
}
else break;
}
return 0;
}