program bai_giai;
uses crt;
var A:array[1..1000] of integer;
n,i,t,j,tg:integer;
begin
clrscr;
repeat
write('Nhap n: '); readln(n);
if n<15 then writeln('n phai lon hon hoac bang 15. Nhap lai.');
until n>=15;
t:=0;
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(A[i]);
if A[i]<0 then t:=t+A[i];
end;
writeln('Tong cac so am la: ',t);
for i:=1 to n-1 do
for j:=i+1 to n do
if A[i]<A[j] then
begin
tg:=A[i];
A[i]:=A[j];
A[j]:=tg;
end;
write('Day sap xep giam dan la: ');
for i:=1 to n do write(A[i],' ');
readln;
end.