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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    }
} 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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    }
} 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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    } 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 sum = 0; sum 0 for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        } {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        } int temp = Integer.parseInt(sc.next()); temp Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc x[i] = temp x[i] x i temp sum += temp sum temp int ans = 0; ans 0 int ans2 = 0; ans2 0 for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        } {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        } ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2) ans Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2) Math.pow Math x[i] - (int)Math.ceil(sum * 1.0 / n) x[i] x i (int)Math.ceil(sum * 1.0 / n) Math.ceil Math sum * 1.0 / n sum * 1.0 sum 1.0 n 2 ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2) ans2 Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2) Math.pow Math x[i] - (int)Math.floor(sum * 1.0 / n) x[i] x i (int)Math.floor(sum * 1.0 / n) Math.floor Math sum * 1.0 / n sum * 1.0 sum 1.0 n 2 System.out.println(Math.min(ans, ans2)) System.out.println System.out System System.out Math.min(ans, ans2) Math.min Math ans ans2 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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    }
} 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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    }
} Main
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 sum = 0;
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            x[i] = temp;
            sum += temp;
        }
        int ans = 0;
        int ans2 = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.pow(x[i] - (int)Math.ceil(sum * 1.0 / n), 2);
            ans2 += Math.pow(x[i] - (int)Math.floor(sum * 1.0 / n), 2);
        }
        System.out.println(Math.min(ans, ans2));
    }
}