program Azadacha;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
     k,i,n:Longint;
     a:array [1..100] of Int64;
begin
  k:=0;
 Readln(n);
  for i:=1 to n do
  begin
    Read(a[i]);
  end;
  for i:=1 to n do
  begin
    a[i]:=a[i]-2;
  if a[i]=a[i-1] then
   k:=k+a[i]+a[i-1];
   if a[i]<>a[i-1] then
   k:=k+a[i-1]-1;
  end;
  Writeln(k-1);
  Readln(n);
end.