from sys import stdin
from decimal import Decimal, ROUND_HALF_UP

n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))
p = sum(data) / n

#p should be int
p_int = (Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP))

Sum = 0
for i in data:
	Sum  += (i - p_int) ** 2 
print(Sum) from sys import stdin from decimal import Decimal, ROUND_HALF_UP n = int(stdin.readline().rstrip()) n int(stdin.readline().rstrip()) int stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip data = list(map(int, stdin.readline().rstrip().split())) data list(map(int, stdin.readline().rstrip().split())) list map(int, stdin.readline().rstrip().split()) map int stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split p = sum(data) / n p sum(data) / n sum(data) sum data n p_int = (Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP)) p_int Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP) (p).quantize (p) Decimal p quantize Decimal('1') Decimal '1' ROUND_HALF_UP Sum = 0 Sum 0 for i in data:
	Sum  += (i - p_int) ** 2  i data Sum  += (i - p_int) ** 2 Sum (i - p_int) ** 2 i - p_int i p_int 2 print(Sum) print Sum Sum  += (i - p_int) ** 2 (i - p_int) ** 2 Sum p_int = (Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP)) Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP) p_int n = int(stdin.readline().rstrip()) int(stdin.readline().rstrip()) n p = sum(data) / n sum(data) / n p data = list(map(int, stdin.readline().rstrip().split())) list(map(int, stdin.readline().rstrip().split())) data Sum = 0 0 Sum
from sys import stdin
from decimal import Decimal, ROUND_HALF_UP

n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))
p = sum(data) / n

#p should be int
p_int = (Decimal(p).quantize(Decimal('1'), ROUND_HALF_UP))

Sum = 0
for i in data:
	Sum  += (i - p_int) ** 2 
print(Sum)