#include<iostream>
using namespace std;
int main(void)
{
int up = 6, down = 4, stop = 5, total;
while (cin >> total && total != 0)
{
int time = 0, cur = 0, aim = 0;
while (total--)
{
cin >> aim;
if (aim >= cur)
{
time += (aim - cur) * up + stop;
cur = aim;
}
else
{
time += (cur - aim) * down + stop;
cur = aim;
}
}
cout << time << endl;
}
return 0;
}
using namespace std;
int main(void)
{
int up = 6, down = 4, stop = 5, total;
while (cin >> total && total != 0)
{
int time = 0, cur = 0, aim = 0;
while (total--)
{
cin >> aim;
if (aim >= cur)
{
time += (aim - cur) * up + stop;
cur = aim;
}
else
{
time += (cur - aim) * down + stop;
cur = aim;
}
}
cout << time << endl;
}
return 0;
}