from sys import stdin
from math import ceil, floor
n = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
m = sum(data) / len(data)
ceil_m = sum([(x-ceil(m))**2 for x in data])
floor_m = sum([(x-floor(m))**2 for x in data])
print(min(ceil_m, floor_m)) from sys import stdin from math import ceil, floor n = int(stdin.readline().rstrip()) n int(stdin.readline().rstrip()) int stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip int(x) for x in stdin.readline().rstrip().split() for x in stdin.readline().rstrip().split() x stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for x in stdin.readline().rstrip().split() int(x) int x data = [int(x) for x in stdin.readline().rstrip().split()] data [int(x) for x in stdin.readline().rstrip().split()] m = sum(data) / len(data) m sum(data) / len(data) sum(data) sum data len(data) len data (x-ceil(m))**2 for x in data for x in data x data for x in data (x-ceil(m))**2 x-ceil(m) x ceil(m) ceil m 2 ceil_m = sum([(x-ceil(m))**2 for x in data]) ceil_m sum([(x-ceil(m))**2 for x in data]) sum [(x-ceil(m))**2 for x in data] (x-floor(m))**2 for x in data for x in data x data for x in data (x-floor(m))**2 x-floor(m) x floor(m) floor m 2 floor_m = sum([(x-floor(m))**2 for x in data]) floor_m sum([(x-floor(m))**2 for x in data]) sum [(x-floor(m))**2 for x in data] print(min(ceil_m, floor_m)) print min(ceil_m, floor_m) min ceil_m floor_m floor_m = sum([(x-floor(m))**2 for x in data]) sum([(x-floor(m))**2 for x in data]) floor_m data = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] data m = sum(data) / len(data) sum(data) / len(data) m n = int(stdin.readline().rstrip()) int(stdin.readline().rstrip()) n ceil_m = sum([(x-ceil(m))**2 for x in data]) sum([(x-ceil(m))**2 for x in data]) ceil_m
from sys import stdin
from math import ceil, floor
n = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
m = sum(data) / len(data)
ceil_m = sum([(x-ceil(m))**2 for x in data])
floor_m = sum([(x-floor(m))**2 for x in data])
print(min(ceil_m, floor_m))
