# Arup Guha
# 12/3/2023
# Solution to 2023 UCF HS Online D1/D2 Problem: Lior's Books

# Get input
n = int(input())
nums = [int(x) for x in input().split()]
nums.sort()

# Get total
tot = 0
for x in nums:
    tot += x

# Can't do it.
if tot%n != 0:
    print("impossible")

# It can work.
else:

    # Just count all stacks that need books and see how many.
    res = 0
    for x in nums:
        if x < tot//n:
            res += (tot//n - x)
    print(res)
