import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] x = new int[n]; x new int[n] n float ave = 0; ave 0 for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            x[i] = sc.nextInt();
            ave += x[i];
        } {
            x[i] = sc.nextInt();
            ave += x[i];
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc ave += x[i] ave x[i] x i ave = Math.round(ave / x.length) ave Math.round(ave / x.length) Math.round Math ave / x.length ave x.length x x.length int count; count int counter = 0; counter 0 for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        } int j = 0; int j = 0; j 0 j < x.length j x.length x x.length j++ j++ j {
            count = x[j] - (int) ave;
            counter += count * count;
        } {
            count = x[j] - (int) ave;
            counter += count * count;
        } count = x[j] - (int) ave count x[j] - (int) ave x[j] x j (int) ave counter += count * count counter count * count count count System.out.println(counter) System.out.println System.out System System.out counter String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        float ave = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            ave += x[i];
        }
        ave = Math.round(ave / x.length);

        int count;
        int counter = 0;
        for (int j = 0; j < x.length; j++) {
            count = x[j] - (int) ave;
            counter += count * count;
        }
        System.out.println(counter);
    }
}