import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
} Main public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int N = stdIn.nextInt(); N stdIn.nextInt() stdIn.nextInt stdIn int[] X =new int[N]; X new int[N] N for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            X[i] = stdIn.nextInt();
        } {
            X[i] = stdIn.nextInt();
        } X[i] = stdIn.nextInt() X[i] X i stdIn.nextInt() stdIn.nextInt stdIn stdIn.close() stdIn.close stdIn Arrays.sort(X) Arrays.sort Arrays X int[] sum = new int[X[N-1] - X[0] + 1]; sum new int[X[N-1] - X[0] + 1] X[N-1] - X[0] + 1 X[N-1] - X[0] X[N-1] X N-1 N 1 X[0] X 0 1 for (int i = 0; i <= X[N-1] - X[0]; i++) {
            for (int j = 0; j < N; j++) {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            }
        } int i = 0; int i = 0; i 0 i <= X[N-1] - X[0] i X[N-1] - X[0] X[N-1] X N-1 N 1 X[0] X 0 i++ i++ i {
            for (int j = 0; j < N; j++) {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            }
        } {
            for (int j = 0; j < N; j++) {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            }
        } for (int j = 0; j < N; j++) {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            } int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            } {
                sum[i] += Math.pow(X[j] - (X[0] + i), 2);
            } sum[i] += Math.pow(X[j] - (X[0] + i), 2) sum[i] sum i Math.pow(X[j] - (X[0] + i), 2) Math.pow Math X[j] - (X[0] + i) X[j] X j (X[0] + i) X[0] X 0 i 2 Arrays.sort(sum) Arrays.sort Arrays sum System.out.println(sum[0]) System.out.println System.out System System.out sum[0] sum 0 String[] args args public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();
        int[] X =new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = stdIn.nextInt();
        }
        stdIn.close();

        Arrays.sort(X);

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

        Arrays.sort(sum);
        System.out.println(sum[0]);
    }
}