import java.util.*;

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

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