solution
#include <iostream>
using namespace std;
int up(int x,int y)
{
int temp=5;
temp+=(y-x)*6;
return temp;
}
int down(int x,int y)
{
int temp=5;
temp+=(x-y)*4;
return temp;
}
int main()
{
int n;
cin>>n;
int idx=0;
int ans=0;
while(n--)
{
int x;
cin>>x;
if(x>idx){
ans+=up(idx,x);
}
else {
ans+=down(idx,x);
}
idx=x;
}
cout<<ans;
}