var
a : array [1..100] of real;
n, i : integer;
flag : boolean;
sum : real;
begin
read (n);
for i := 1 to n do read (a[i]);
flag := false; sum := 0;
for i := n downto 1 do
if flag then sum := sum + a[i]
else if a[i] > 0 then flag := true;
writeln (sum);
end.