#!/bin/bash

''':'

docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \

   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"

exit $?

'''

import sys



def _i(): return int(sys.stdin.readline().strip())

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]



n = _i()

x = sorted(_ia())



ans = -1

for p in range(min(x), max(x)+1):

   tmp = 0

   for xx in x:

      tmp += (xx-p)**2

   if ans <0 or tmp<ans: ans= tmp

print(ans)
import numpy as np





def main():

    _ = eval(input())

    x = np.asarray(list(map(int, input().split())))

    p = int(np.round(np.average(x)))

    print((np.sum((x - p) ** 2)))





if __name__ == "__main__":

    main()

#!/bin/bash
""":'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
"""
import sys


def _i():
    return int(sys.stdin.readline().strip())


def _ia():
    return [int(x) for x in sys.stdin.readline().strip().split()]


n = _i()
x = sorted(_ia())
ans = -1
for p in range(min(x), max(x) + 1):
    tmp = 0
    for xx in x:
        tmp += (xx - p) ** 2
    if ans < 0 or tmp < ans:
        ans = tmp
print(ans)

import numpy as np


def main():
    _ = eval(input())
    x = np.asarray(list(map(int, input().split())))
    p = int(np.round(np.average(x)))
    print((np.sum((x - p) ** 2)))


if __name__ == "__main__":
    main()

-#!/bin/bash -""":' -docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \ -   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp" -exit $? -""" -import sys +import numpy as np -def _i(): -    return int(sys.stdin.readline().strip()) +def main(): +    _ = eval(input()) +    x = np.asarray(list(map(int, input().split()))) +    p = int(np.round(np.average(x))) +    print((np.sum((x - p) ** 2))) -def _ia(): -    return [int(x) for x in sys.stdin.readline().strip().split()] - - -n = _i() -x = sorted(_ia()) -ans = -1 -for p in range(min(x), max(x) + 1): -    tmp = 0 -    for xx in x: -        tmp += (xx - p) ** 2 -    if ans < 0 or tmp < ans: -        ans = tmp -print(ans) +if __name__ == "__main__": +    main()