n = int(input())
scores = list(map(int, input().split()))
avg = round(sum(scores) / n)
min_diff = float('inf')
answer = 0
for s in scores:
diff = abs(s - avg)
if diff < min_diff or (diff == min_diff and s > answer):
min_diff = diff
answer = s
print(avg, answer)
To embed this project on your website, copy the following code and paste it into your website's HTML: