Const nx=30;
var i,j,n,m,q,r:integer;A:array[1..nx,1..nx] of integer;d,Sn,min:real;
begin
Write('Введите размер массива ');Readln(n);min:=100;
for i:=1 to n do begin
for j:=1 to n do begin
A[i,j]:=random(100)-2;write(A[i,j]:4);m:= m + A[i,j];end;writeln;end;
Sn:= m/n/n;write(m:9,Sn:9:4);writeln;
for i:=1 to n do begin
for j:=1 to n do begin
d:=abs(sn - A[i,j]);
if d < min then begin r:=i; q:=j; min := d;end;end;end;
write(A[r,q]:4,r:4,q:4);
end.