import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
} Main public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    } main {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Integer n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] x = new Integer[n]; x new Integer[n] n 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 int sum = 0; sum 0 for (int num : x) {
            sum += num;
        } int num x {
            sum += num;
        } {
            sum += num;
        } sum += num sum num int ave = (int)Math.round((double)sum / n); ave (int)Math.round((double)sum / n) Math.round Math (double)sum / n (double)sum n int result = 0; result 0 for (int num : x) {
            result += Math.pow(num - ave, 2);
        } int num x {
            result += Math.pow(num - ave, 2);
        } {
            result += Math.pow(num - ave, 2);
        } result += Math.pow(num - ave, 2) result Math.pow(num - ave, 2) Math.pow Math num - ave num ave 2 System.out.println(result) System.out.println System.out System System.out result sc.close() sc.close sc String args[] args public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
} public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int sum = 0;
        for (int num : x) {
            sum += num;
        }
        int ave = (int)Math.round((double)sum / n);

        int result = 0;
        for (int num : x) {
            result += Math.pow(num - ave, 2);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}
