def Rally():
    # 入力
    N = int(input())
    X = list(map(int, input().split()))
    # リストの最大値と最小値
    max_num = max(X)
    min_num = min(X)
    # Pの座標を移動させて各座標の体力消耗を調べる
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
    return min(min_sum)

result = Rally()
print(result) def Rally():
    # 入力
    N = int(input())
    X = list(map(int, input().split()))
    # リストの最大値と最小値
    max_num = max(X)
    min_num = min(X)
    # Pの座標を移動させて各座標の体力消耗を調べる
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
    return min(min_sum) 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 max_num = max(X) max_num max(X) max X min_num = min(X) min_num min(X) min X min_sum = list() min_sum list() list for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
     P range(min_num, max_num+1) range min_num max_num+1 max_num 1 sum = 0 sum 0 for i in range(N):
            sum += (X[i] - P)**2
         i range(N) range N sum += (X[i] - P)**2 sum (X[i] - P)**2 X[i] - P X[i] X i P 2 min_sum.append(sum) min_sum.append min_sum append sum return min(min_sum) min(min_sum) min min_sum result = Rally() result Rally() Rally print(result) print result result = Rally() Rally() result def Rally():
    # 入力
    N = int(input())
    X = list(map(int, input().split()))
    # リストの最大値と最小値
    max_num = max(X)
    min_num = min(X)
    # Pの座標を移動させて各座標の体力消耗を調べる
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
    return min(min_sum) def Rally():
    # 入力
    N = int(input())
    X = list(map(int, input().split()))
    # リストの最大値と最小値
    max_num = max(X)
    min_num = min(X)
    # Pの座標を移動させて各座標の体力消耗を調べる
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
    return min(min_sum) Rally
def Rally():
    # 入力
    N = int(input())
    X = list(map(int, input().split()))
    # リストの最大値と最小値
    max_num = max(X)
    min_num = min(X)
    # Pの座標を移動させて各座標の体力消耗を調べる
    min_sum = list()
    for P in range(min_num, max_num+1):
        sum = 0
        for i in range(N):
            sum += (X[i] - P)**2
        min_sum.append(sum)
    # 戻り値
    return min(min_sum)

result = Rally()
print(result)