{$mode objfpc} {$coperators on} uses ghashmap,math; const fi='input.txt'; fo='output.txt'; procedure fileio; begin assign(input,fi); reset(input); assign(output,fo); rewrite(output); end; type Tmyhash=class public class function hash(a:int64; b:sizeUint):Sizeuint; end; Tmymap=specialize Thashmap; class function Tmyhash.hash(a:int64; b:sizeuint):sizeuint; begin exit(a mod b); end; var n,top:longint; a:array[0..10005] of int64; f:Tmymap; procedure enter; begin readln(n); end; procedure sort(l,r: longint); var i,j: longint; x,y:int64; begin i:=l; j:=r; x:=a[random(r-l+1)+l]; repeat while a[i]j) then begin y:=a[i]; a[i]:=a[j]; a[j]:=y; inc(i); j:=j-1; end; until i>j; if ln then break else if n mod a[i]=0 then begin result:=max(result,tinh(n div a[i])*a[i]); end; result+=1; f[n]:=result; end; function calc(n:int64):int64; var i:longint; begin if F.contains(n) then exit(F[n]); //pttsnt top:=1; a[1]:=n; for i:=2 to trunc(sqrt(n)) do if n mod i=0 then begin inc(top); a[top]:=i; if n div i<>i then begin inc(top); a[top]:=n div i; end; end; sort(1,top); result:=0; for i:=1 to top do result:=max(tinh(n div a[i])*a[i],result); result+=1; F[n]:=result; end; procedure solve; var i:longint; res,so:int64; begin randomize; res:=0; F:=Tmymap.Create; f[1]:=1; for i:=1 to n do begin read(so); res+=calc(so); end; writeln(res); end; begin //fileio; enter; solve; end.