题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1008
//C++代码
#include<iostream>
using namespace std;
int main(){
int n;
while(cin>>n,n){
int t=0,a,b,i;
cin>>a;
t+=6*a+5;
for(i=2;i<=n;i++){
cin>>b;
if(b>a) t+=6*(b-a)+5;
else t+=4*(a-b)+5;
a=b;
}
cout<<t<<endl;
}
return 0;
}