import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    } 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 double minSum = 1000000000; minSum 1000000000 Arrays.sort(X) Arrays.sort Arrays X for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        } int j = X[0]; int j = X[0]; j X[0] X 0 j <= X[N - 1] j X[N - 1] X N - 1 N 1 j++ j++ j {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        } {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        } double sum = 0; sum 0 int k = 0; k 0 for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            } k = 0; k = 0 k 0 k < N k N k++ k++ k {
                sum += Math.pow((X[k] - j), 2);
            } {
                sum += Math.pow((X[k] - j), 2);
            } sum += Math.pow((X[k] - j), 2) sum Math.pow((X[k] - j), 2) Math.pow Math (X[k] - j) X[k] X k j 2 minSum = Math.min(sum, minSum) minSum Math.min(sum, minSum) Math.min Math sum minSum System.out.println((int)minSum) System.out.println System.out System System.out (int)minSum String[] args args
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        // int P = null;

        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        
        double minSum = 1000000000;
        Arrays.sort(X); 

        
        for (int j = X[0]; j <= X[N - 1]; j++) {
            double sum = 0;
            int k = 0;
            for (k = 0; k < N; k++) {
                sum += Math.pow((X[k] - j), 2);
            }

            // sum = Math.pow((X[0] - j), 2) + Math.pow((X[N - 1] - j), 2);
            // System.out.println("j:" + j + " k:" + k + " 合計:" + sum);
            minSum = Math.min(sum, minSum);
        }

        System.out.println((int)minSum);
    }
}