def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best)

abc156c_rally() def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best) abc156c_rally n = int(input()) n int(input()) int input() input x = list(map(int, input().split())) x list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split min_x, max_x = min(x), max(x) min_x min(x) min x max_x max(x) max x best = float('inf') best float('inf') float 'inf' for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
     i range(min_x, max_x + 1) range min_x max_x + 1 max_x 1 total = 0 total 0 for v in x:
            total += (v - i) * (v - i)
         v x total += (v - i) * (v - i) total (v - i) * (v - i) v - i v i v - i v i if best > total:
            best = total
     best > total best total best = total best total print(best) print best abc156c_rally() abc156c_rally def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best) def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best) abc156c_rally
def abc156c_rally():
    n = int(input())
    x = list(map(int, input().split()))
    min_x, max_x = min(x), max(x)
    best = float('inf')
    for i in range(min_x, max_x + 1):
        total = 0
        for v in x:
            total += (v - i) * (v - i)
        if best > total:
            best = total
    print(best)

abc156c_rally()