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];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
} 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];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    } 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 int sum = 0; sum 0 int ans = 0; ans 0 for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } int i = 0 ; int i = 0 ; i 0 i< N i N i++ i++ i {
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } {
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc sum = sum + X[i] sum sum + X[i] sum X[i] X i double x =(double) sum/N; x (double) sum/N (double) sum N double M =Math.round(x); M Math.round(x) Math.round Math x int ans1 = 0; ans1 0 for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        } int i= 0 ; int i= 0 ; i 0 i< X.length i X.length X X.length i++ i++ i {
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        } {
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        } ans1=X[i] ans1 X[i] X i ans +=(int) Math.pow(ans1-M,2) ans (int) Math.pow(ans1-M,2) Math.pow Math ans1-M ans1 M 2 System.out.println(ans) System.out.println System.out System System.out ans 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];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X[] = new int[N];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
} 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];
        int sum = 0;
        int ans = 0;
        for (int i = 0 ; i< N ; i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        double x =(double) sum/N;
        double M =Math.round(x);
        int ans1 = 0;
        for (int i= 0 ; i< X.length;i++ ){
            ans1=X[i];
            ans +=(int) Math.pow(ans1-M,2);
        }
        System.out.println(ans);
    }
}
