var i,M,K,N:integer;
begin
Readln(N);
K:=0;
for i:=1 to N do
readln(M);
if M mod 10 = 9
then
K:=K + M;
end;
write(K);
end.
var i,M,K,N:integer;
begin
Readln(N);
K:=0;
for i:=1 to N do
begin
readln(M);
if M mod 10 = 9
then
begin
K:=K + M;
end;
end;
write(K);
end.