import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] x = new int[n];
        for(int i =0; i<n ; i++){
            x[i] = sc.nextInt();
        }

        int minX = Arrays.stream(x).min().getAsInt();
        int maxX = Arrays.stream(x).max().getAsInt();

        int minValue = Integer.MAX_VALUE;
        int[] power = new int[n];
        for(int i = minX; i <= maxX; i++){ //i是p可以选择的位置
            for(int j = 0; j<x.length; j++){ //j是x的下标
                power[j] = (x[j]-i)*(x[j]-i);
            }
            minValue = Math.min(minValue, Arrays.stream(power).sum());
        }

        System.out.println(minValue);
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz