Program prog;
uses crt;
var a:array[1..100] of integer;
s,i:integer;
begin
for i:=1 to 10 do
begin
write('a[',i,'] = ');
readln(a[i]);
end;
for i:=1 to 10 do
begin
if (a[i]>=0) and ( a[i] mod 10 = 4) then
s:=s+a[i]
end;
writeln;
writeln('S = ', s);
end.