import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] X = new int[N]; X new int[N] N for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            X[i] = sc.nextInt();
        } {
            X[i] = sc.nextInt();
        } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc Arrays.sort(X) Arrays.sort Arrays X int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        } int P = X[0]; int P = X[0]; P X[0] X 0 P <= X[X.length - 1] P X[X.length - 1] X X.length - 1 X.length X X.length 1 P++ P++ P {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        } {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        } int sum = 0; sum 0 for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            } int x X {
                sum += Math.abs(x - P) * Math.abs(x - P);
            } {
                sum += Math.abs(x - P) * Math.abs(x - P);
            } sum += Math.abs(x - P) * Math.abs(x - P) sum Math.abs(x - P) * Math.abs(x - P) Math.abs(x - P) Math.abs Math x - P x P Math.abs(x - P) Math.abs Math x - P x P min = Math.min(min, sum) min Math.min(min, sum) Math.min Math min sum System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }
        Arrays.sort(X);
        int min = Integer.MAX_VALUE;
        for (int P = X[0]; P <= X[X.length - 1] ; P++) {
            int sum = 0;
            for(int x: X){
                sum += Math.abs(x - P) * Math.abs(x - P);
            }
            min = Math.min(min, sum);
        }
        System.out.println(min);
    }
}