#include
using namespace std;
int main()
{
int n,i,time;
while(cin>>n,n)
{
time=0;
int *h=new int [n];
cin>>h[0];
time+=h[0]*6+5;
for(i=1;i
cin>>h[i];
if(h[i]>h[i-1])
time+=(h[i]-h[i-1])*6+5;
else if(h[i]
else //同一层也要加5
time+=5;
}
cout<