背景:水
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void){
int t;
while(scanf("%d",&t),t){
int ans=0,temp1,temp2=0;
for(int i=1;i <= t;i++){
scanf("%d",&temp1);
if(temp1 > temp2) ans+=(temp1-temp2)*6+5;
else if(temp2 > temp1) ans+=(temp2-temp1)*4+5;
else ans+=5;
temp2=temp1;
}
printf("%d\n",ans);
}
return 0;
}