program ReplaceElements;
var
arr: array[1.10] of Integer;
i, sum, min, max, avg: Integer;
begin
sum := 0;
min := 9999;
max := -9999;
for i := 1 to 10 do
begin
Write('Enter element ', i, ': ');
Readln(arr[i]);
sum := sum + arr[i];
if arr[i] < min then
min := arr[i];
if arr[i] > max then
max := arr[i];
end;
avg := sum div 10;
for i := 1 to 10 do
begin
if arr[i] < avg then
arr[i] := min
else if arr[i] > avg then
arr[i] := max;
Write(arr[i], ' ');
end;
end.