//Pascal ABC.NET v3.0
var ma:array of array of integer;
i,j,s,m:integer;
begin
randomize;
readln(m);
setlength(ma,m+1);
for i:=1 to m do
setlength(ma[i],m+1);
writeln('Matrix:');
for i:=1 to m do
begin;
writeln;
for j:=1 to m do
begin;
ma[i,j]:=random(-30,40);
write(ma[i,j]:4);
end;
end;
for i:=1 to m do
for j:=i+1 to m do
s+=ma[i,j];
writeln;
writeln('Result:',s);
end.