uses crt;
const fi='dlra.txt'
var a:array[1..100]of integer;
i,n,h:integer;
f1:text;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
assign(f1,fi); rewrite(f1);
h:=0;
for i:=1 to n do
if a[i] mod 3<>0 then
begin
write(f1,a[i]:4);
h:=h-a[i];
end;
writeln(f1);
writeln(f1,h);
close(f1);
readln;
end.