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

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    }

    private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    }
} 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    }

    private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    }
} 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    } 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    } 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        } {
            int N = sc.nextInt();
            int[] X = new int[N];
            for (int i = 0; i < N; i++) {
                X[i] = sc.nextInt();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        } 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 int sum = 0; sum 0 for (int i = 0; i < N; i++) {
                sum += X[i];
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                sum += X[i];
            } {
                sum += X[i];
            } sum += X[i] sum X[i] X i int mean = sum / N; mean sum / N sum N int min = (int) 1e9; min (int) 1e9 min = Math.min(min, calculateCost(N, X, mean)) min Math.min(min, calculateCost(N, X, mean)) Math.min Math min calculateCost(N, X, mean) calculateCost N X mean min = Math.min(min, calculateCost(N, X, mean + 1)) min Math.min(min, calculateCost(N, X, mean + 1)) Math.min Math min calculateCost(N, X, mean + 1) calculateCost N X mean + 1 mean 1 System.out.println(min) System.out.println System.out System System.out min String[] args args private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    } calculateCost {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    } int cost = 0; cost 0 for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            cost += (X[i] - mean) * (X[i] - mean);
        } {
            cost += (X[i] - mean) * (X[i] - mean);
        } cost += (X[i] - mean) * (X[i] - mean) cost (X[i] - mean) * (X[i] - mean) (X[i] - mean) X[i] X i mean (X[i] - mean) X[i] X i mean return cost; cost int N N int[] X X int mean mean 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    }

    private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    }
} 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    }

    private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    }
} 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();
            }

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += X[i];
            }
            int mean = sum / N;

            int min = (int) 1e9;
            min = Math.min(min, calculateCost(N, X, mean));
            min = Math.min(min, calculateCost(N, X, mean + 1));

            System.out.println(min);
        }
    }

    private static int calculateCost(int N, int[] X, int mean) {
        int cost = 0;
        for (int i = 0; i < N; i++) {
            cost += (X[i] - mean) * (X[i] - mean);
        }
        return cost;
    }
}