import random
def get_randoms(n, avg, min_val, max_val, repeats=20):
result = [avg] * n
for i in range(repeats):
i1, i2 = random.sample(range(n), 2) # выбираем 2 случайных индекса
v1, v2 = (result[i1], result[i2])
max_delta = min(v1 - min_val, max_val - v2)
rand_delta = random.randint(0, max_delta)
v1 -= rand_delta
v2 += rand_delta
result[i1] = v1
result[i2] = v2
return result
randoms = get_randoms(5, 89, 60, 100)
print(randoms, sum(randoms) / 5) # [95, 71, 98, 92, 89] 89.0
randoms = get_randoms(5, 89, 60, 100, 50)
print(randoms, sum(randoms) / 5) # [95, 97, 75, 81, 97] 89.0