import java.util.Scanner;

public class Main {

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