var
n,b,i,l,c,cc:longint;
a:array[1..10000000] of longint;
begin
readln(n);
for i:=1 to n do read(a[i]);
l:=0; b:=0; i:=0;
repeat
inc(i);
if a[i]>l then begin b:=b+(a[i]-l)*6+6; l:=a[i]; end;
if a[i]<l then begin b:=b+(l-a[i])*4+6; l:=a[i]; end;
for c:=i+1 to n do if a[c]=a[i] then
begin
b:=b+1;
for cc:=c to n do a[cc]:=a[cc+1];
n:=n-1;
end;
until i=n;
b:=b+l*4;
writeln(b);
end.