import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
} Main public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc ArrayList<Integer> X = new ArrayList<>(); X new ArrayList<>() double sum = 0; sum 0 for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            X.add(sc.nextInt());
            sum+=X.get(i);
        } {
            X.add(sc.nextInt());
            sum+=X.get(i);
        } X.add(sc.nextInt()) X.add X sc.nextInt() sc.nextInt sc sum+=X.get(i) sum X.get(i) X.get X i sum/=X.size() sum X.size() X.size X sum = Math.round(sum) sum Math.round(sum) Math.round Math sum int opt = 0; opt 0 for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2); int i=0; int i=0; i 0 i<N i N i++ i++ i opt+=Math.pow(X.get(i)-sum,2); opt+=Math.pow(X.get(i)-sum,2) opt Math.pow(X.get(i)-sum,2) Math.pow Math X.get(i)-sum X.get(i) X.get X i sum 2 System.out.println(opt) System.out.println System.out System System.out opt String [] args args public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
} public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> X = new ArrayList<>();
        double sum = 0;
        for(int i=0;i<N;i++){
            X.add(sc.nextInt());
            sum+=X.get(i);
        }
        sum/=X.size();
        sum = Math.round(sum);
        int opt = 0;
        for(int i=0;i<N;i++) opt+=Math.pow(X.get(i)-sum,2);
        System.out.println(opt);
    }
}