def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e)

if __name__ == '__main__':
    main() def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e) main n = int(input()) n int(input()) int input() input int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x X = [int(x) for x in input().split()] X [int(x) for x in input().split()] min_x = min(X) min_x min(X) min X max_x = max(X) max_x max(X) max X min_e = 10**6 min_e 10**6 10 6 for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
     i range(min_x, max_x+1) range min_x max_x+1 max_x 1 error = 0 error 0 for x in X:
            error += (x-i) ** 2
         x X error += (x-i) ** 2 error (x-i) ** 2 x-i x i 2 min_e = min(min_e, error) min_e min(min_e, error) min min_e error print(min_e) print min_e if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e) def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e) main
def main():
    n = int(input())
    X = [int(x) for x in input().split()]
    min_x = min(X)
    max_x = max(X)
    min_e = 10**6
    for i in range(min_x, max_x+1):
        error = 0
        for x in X:
            error += (x-i) ** 2
        min_e = min(min_e, error)
    print(min_e)

if __name__ == '__main__':
    main()