uses crt;
const n=5;
var a:array[1..n,1..n] of integer;
i,j,sum:integer;
begin
clrscr;
writeln('Введите ',n*n,' матрицу:');
for i:=1 to n do
for j:=1 to n do
begin
write('a[',i,',',j,']=');
readln(a[i,j]);
end;
clrscr;
writeln('Матрица:');
sum:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
write(a[i,j]:4);
if j=i then s:=sum+sqr(a[i,j]);
end;
writeln;
end;
write('Сумма квадратов элементов диагонали=',s);
readln
end.