#include<iostream>
using namespace std;
int go(int c, int n)
{
if(c<n) return (n-c)*6+5;
else return (c-n)*4+5;
}
void main()
{
int n,cur,next,time;
while(cin>>n)
{
if(n==0) break;
time=0;
cur=0;
while(n--)
{
cin>>next;
time+=go(cur,next);
cur=next;
}
cout<<time<<endl;
}
}
using namespace std;
int go(int c, int n)
{
if(c<n) return (n-c)*6+5;
else return (c-n)*4+5;
}
void main()
{
int n,cur,next,time;
while(cin>>n)
{
if(n==0) break;
time=0;
cur=0;
while(n--)
{
cin>>next;
time+=go(cur,next);
cur=next;
}
cout<<time<<endl;
}
}