/*
水题:模拟
一开始把意思读错了!!
The numbers denote at which floors the elevator will stop, in specified order.
少读了in specified order!导致自己用排序求其最值!
题意:
n个整数,后一个若比前一个大,ans+=差值*6
否则ans+=差值*4
ans+=5意为在每个整数点停留5秒
*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
using namespace std;
#define For1(i,a,b) for (i=a;i<b;i++)
#define For2(i,a,b) for (i=a;i<=b;i++)
#define Dec(i,a,b) for (i=a;i>b;i--)
#define Dec2(i,a,b) for (i=a;i>=b;i--)
#define Sca(x) scanf("%d",&x)
#define Fill(x,a) memset(x,a,sizeof(x))
#define MAXN 0x7fffffff
int main()
{
int n,m,now,i,ans,before;
while(cin>>n)
{
if (!n) break;
ans=now=before=0;
For2(i,1,n)
{
Sca(now);
if (now>before) ans+=6*(now-before);
else ans+=4*(before-now);
ans+=5;
before=now;
}
cout<<ans<<endl;
}
return 0;
}