#include <iostream>
using namespace std;
int main(){
int n,sum,start,end;//start当前楼层,end前往楼层
while(1){
cin>>n;
if(n==0) break;//n为0结束任务
start=0;//每次从0层开始
sum=n*5;//n个任务总共停留的时间
while(n--){
cin>>end;
if(start<end)//上升
sum+=(end-start)*6;
else //下降
sum+=(start-end)*4;
start=end;//更新当前楼层
}
cout<<sum<<endl; //每结束一组任务输出并换行
}
return 0;
}
#转载请注明出处!