import java.util.Scanner;
public class p1008 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
if(n==0){
break;
}
//初始化数据,中间停留时间,上升时间,下降时间
int sleep=5;
int uptime=6;
int dowmtime=4;
int []a=new int[n+1];
int count=0;//统计所需要的时间
//输入数据
a[0]=0;
for(int i=1;i<n+1;i++){
a[i]=sc.nextInt();
if(a[i]>a[i-1]){
count=count+(a[i]-a[i-1])*uptime+sleep;
}else{
count=count+(a[i-1]-a[i])*dowmtime+sleep;
}
}
System.out.println(count);
}
}
}