import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    }
} Main public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    } main {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    } 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 double sum = 0; sum 0 for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = sc.nextInt();
			sum += x[i];
		} {
			x[i] = sc.nextInt();
			sum += x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i sum /= n sum n int p; p if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		} Math.ceil(sum) - sum >= sum - Math.floor(sum) Math.ceil(sum) - sum Math.ceil(sum) Math.ceil Math sum sum sum - Math.floor(sum) sum Math.floor(sum) Math.floor Math sum {
			p = (int) Math.floor(sum);
		} p = (int) Math.floor(sum) p (int) Math.floor(sum) Math.floor Math sum {
			p = (int) Math.ceil(sum);
		} p = (int) Math.ceil(sum) p (int) Math.ceil(sum) Math.ceil Math sum long ans = 0; ans 0 for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ans += Math.pow(x[i] - p, 2);
		} {
			ans += Math.pow(x[i] - p, 2);
		} ans += Math.pow(x[i] - p, 2) ans Math.pow(x[i] - p, 2) Math.pow Math x[i] - p x[i] x i p 2 System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		double sum = 0;
		
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		
		sum /= n;
		
		int p;
		
		if (Math.ceil(sum) - sum >= sum - Math.floor(sum)){
			p = (int) Math.floor(sum);
		} else {
			p = (int) Math.ceil(sum);
		}
		
		long ans = 0;
		
		for (int i = 0; i < n; i++) {
			ans += Math.pow(x[i] - p, 2);
		}
		
		System.out.println(ans);
		
		sc.close();
    }
}

