Const n=5;
Var
ma:array[1..n,1..n] of integer;
ar:array[1..n*n] of integer;
i,j,k:integer;
begin
randomize;
writeln('Matrix:');
for i:=1 to n do
begin
for j:=1 to n do
begin
ma[i,j]:=random(5);
write(ma[i,j]:4);
end;
writeln;
end;
writeln('Result:');
for i:=1 to n-1 do
for j:=1 to n-i do
begin
inc(k);
ar[k]:=ma[i,j];
end;
for i:=1 to k do
write(ar[i]:4);
end.