import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

} Main public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    } main {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    } try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

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

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) 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 long result = 0; result 0 int P = 0; P 0 for (int i = 0; i < x.length; i++) {
                P += x[i];
            } int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
                P += x[i];
            } {
                P += x[i];
            } P += x[i] P x[i] x i P = Math.round((float) P / x.length) P Math.round((float) P / x.length) Math.round Math (float) P / x.length (float) P x.length x x.length for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            } int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
                result += Math.pow(x[i] - P, 2);
            } {
                result += Math.pow(x[i] - P, 2);
            } result += Math.pow(x[i] - P, 2) result Math.pow(x[i] - P, 2) Math.pow Math x[i] - P x[i] x i P 2 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

} public class Main {
    public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (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();
            }

            long result = 0;

            int P = 0;
            for (int i = 0; i < x.length; i++) {
                P += x[i];
            }

            P = Math.round((float) P / x.length);

            for (int i = 0; i < x.length; i++) {
                result += Math.pow(x[i] - P, 2);
            }

            System.out.println(result);

        }
    }

}