def main():

  from statistics import mean

  from math import floor,ceil



  n = int(eval(input()))

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

  x_mean = mean(x) 

  if x_mean == 0.5:

      greater_than_x = len([i for i in x if i > x_mean])

      if greater_than_x * 2 >= n:

          x_mean = ceil(x_mean)

      else:

          x_mean = floor(x_mean)

  elif x_mean % 1 > 0.5:

      x_mean = ceil(x_mean)

  else:

      x_mean = floor(x_mean)

  x2 = [(num - x_mean)**2 for num in x]

  print((sum(x2)))



main()
import sys

read = sys.stdin.read

def main():

    n, *x = list(map(int, read().split()))

    r = float('inf')

    for i1 in range(1, 101):

        rt = 0

        for xe in x:

            rt += (xe - i1)**2

        r = min(r, rt)

    print(r)



if __name__ == '__main__':

    main()

def main():
    from statistics import mean
    from math import floor, ceil

    n = int(eval(input()))
    x = list(map(int, input().split()))
    x_mean = mean(x)
    if x_mean == 0.5:
        greater_than_x = len([i for i in x if i > x_mean])
        if greater_than_x * 2 >= n:
            x_mean = ceil(x_mean)
        else:
            x_mean = floor(x_mean)
    elif x_mean % 1 > 0.5:
        x_mean = ceil(x_mean)
    else:
        x_mean = floor(x_mean)
    x2 = [(num - x_mean) ** 2 for num in x]
    print((sum(x2)))


main()

import sys

read = sys.stdin.read


def main():
    n, *x = list(map(int, read().split()))
    r = float("inf")
    for i1 in range(1, 101):
        rt = 0
        for xe in x:
            rt += (xe - i1) ** 2
        r = min(r, rt)
    print(r)


if __name__ == "__main__":
    main()

-def main(): -    from statistics import mean -    from math import floor, ceil +import sys -    n = int(eval(input())) -    x = list(map(int, input().split())) -    x_mean = mean(x) -    if x_mean == 0.5: -        greater_than_x = len([i for i in x if i > x_mean]) -        if greater_than_x * 2 >= n: -            x_mean = ceil(x_mean) -        else: -            x_mean = floor(x_mean) -    elif x_mean % 1 > 0.5: -        x_mean = ceil(x_mean) -    else: -        x_mean = floor(x_mean) -    x2 = [(num - x_mean) ** 2 for num in x] -    print((sum(x2))) +read = sys.stdin.read -main() +def main(): +    n, *x = list(map(int, read().split())) +    r = float("inf") +    for i1 in range(1, 101): +        rt = 0 +        for xe in x: +            rt += (xe - i1) ** 2 +        r = min(r, rt) +    print(r) + + +if __name__ == "__main__": +    main()