#include cstdioint main(){ int n; int pre,f; int sum; while(scanf("%d",n)n){ sum=n*5; pre=0; for(int i=0;in;i++){ scanf("%d",f); if(fpre) sum+=(f-pre)*6; else sum+=(pre-f)*4; pre=f; } printf("%d\n",sum); }}
#include <cstdio>
int main(){
int n;
int pre,f;
int sum;
while(scanf("%d",&n)&&n){
sum=n*5;
pre=0;
for(int i=0;i<n;i++){
scanf("%d",&f);
if(f>pre)
sum+=(f-pre)*6;
else
sum+=(pre-f)*4;
pre=f;
}
printf("%d\n",sum);
}
}