import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    }
} import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] X = new int[N]; X new int[N] N int minSum = 2000000; minSum 2000000 int sum = 0; sum 0 for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            X[i] = Integer.parseInt(sc.next());
        } {
            X[i] = Integer.parseInt(sc.next());
        } X[i] = Integer.parseInt(sc.next()) X[i] X i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(X) Arrays.sort Arrays X for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        } int i = X[0]; int i = X[0]; i X[0] X 0 i <= X[N - 1] i X[N - 1] X N - 1 N 1 i++ i++ i {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        } {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        } for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            } int j = 0; int j = 0; j 0 j < N j N j++ j++ j {
                sum += (X[j] - i) * (X[j] - i);
            } {
                sum += (X[j] - i) * (X[j] - i);
            } sum += (X[j] - i) * (X[j] - i) sum (X[j] - i) * (X[j] - i) (X[j] - i) X[j] X j i (X[j] - i) X[j] X j i if (sum < minSum) {
                minSum = sum;
            } sum < minSum sum minSum {
                minSum = sum;
            } minSum = sum minSum sum sum = 0 sum 0 PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) out.println(minSum) out.println out minSum sc.close() sc.close sc out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    }
} Main
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] X = new int[N];
        int minSum = 2000000;
        int sum = 0;

        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(X);

        for (int i = X[0]; i <= X[N - 1]; i++) {
            for (int j = 0; j < N; j++) {
                sum += (X[j] - i) * (X[j] - i);
            }

            if (sum < minSum) {
                minSum = sum;
            }
            sum = 0;
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(minSum);
        sc.close();
        out.flush();
    }
}