#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a[101],i=0,sum=0;
    int up=6,down=4,stay=5;
    while (scanf("%d",&n)!=EOF&&n)
    {
        a[0]=0;
        sum=0;
        for(i=1; i<=n; i++)
            scanf("%d",&a[i]);
        for (i=1; i<=n; i++)
        {
            if(a[i]>a[i-1])
                sum+=(a[i]-a[i-1])*up+stay;
            else
                sum+=(a[i-1]-a[i])*down+stay;
        }
        printf("%d\n",sum);
    }
    return 0;
}

