import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		
		long sumX =0;
		
		for(int i = 0; i < N; i++) {
			sumX += X[i];
		}
		
		double avg = (double)sumX / N;
		
		long p1 = (long)Math.floor(avg);
		long p2 = (long)Math.ceil(avg);
		
		long ans1 = 0, ans2 = 0;
		
		for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		}
		
		System.out.println(Math.min(ans1, ans2));
		

	}
}

 import java.util.*; util.* java class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		
		long sumX =0;
		
		for(int i = 0; i < N; i++) {
			sumX += X[i];
		}
		
		double avg = (double)sumX / N;
		
		long p1 = (long)Math.floor(avg);
		long p2 = (long)Math.ceil(avg);
		
		long ans1 = 0, ans2 = 0;
		
		for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		}
		
		System.out.println(Math.min(ans1, ans2));
		

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		
		long sumX =0;
		
		for(int i = 0; i < N; i++) {
			sumX += X[i];
		}
		
		double avg = (double)sumX / N;
		
		long p1 = (long)Math.floor(avg);
		long p2 = (long)Math.ceil(avg);
		
		long ans1 = 0, ans2 = 0;
		
		for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		}
		
		System.out.println(Math.min(ans1, ans2));
		

	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		
		long sumX =0;
		
		for(int i = 0; i < N; i++) {
			sumX += X[i];
		}
		
		double avg = (double)sumX / N;
		
		long p1 = (long)Math.floor(avg);
		long p2 = (long)Math.ceil(avg);
		
		long ans1 = 0, ans2 = 0;
		
		for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		}
		
		System.out.println(Math.min(ans1, ans2));
		

	} 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 for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			X[i] = sc.nextInt();
		} {
			X[i] = sc.nextInt();
		} X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc sc.close() sc.close sc long sumX =0; sumX 0 for(int i = 0; i < N; i++) {
			sumX += X[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			sumX += X[i];
		} {
			sumX += X[i];
		} sumX += X[i] sumX X[i] X i double avg = (double)sumX / N; avg (double)sumX / N (double)sumX N long p1 = (long)Math.floor(avg); p1 (long)Math.floor(avg) Math.floor Math avg long p2 = (long)Math.ceil(avg); p2 (long)Math.ceil(avg) Math.ceil Math avg long ans1 = 0 ans1 0 ans2 = 0; ans2 0 for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		} {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		} ans1 += (long)Math.pow(X[i] - p1, 2) ans1 (long)Math.pow(X[i] - p1, 2) Math.pow Math X[i] - p1 X[i] X i p1 2 ans2 += (long)Math.pow(X[i] - p2, 2) ans2 (long)Math.pow(X[i] - p2, 2) Math.pow Math X[i] - p2 X[i] X i p2 2 System.out.println(Math.min(ans1, ans2)) System.out.println System.out System System.out Math.min(ans1, ans2) Math.min Math ans1 ans2 String[] args args
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		sc.close();
		
		long sumX =0;
		
		for(int i = 0; i < N; i++) {
			sumX += X[i];
		}
		
		double avg = (double)sumX / N;
		
		long p1 = (long)Math.floor(avg);
		long p2 = (long)Math.ceil(avg);
		
		long ans1 = 0, ans2 = 0;
		
		for(int i = 0; i < N; i++) {
			ans1 += (long)Math.pow(X[i] - p1, 2);
			ans2 += (long)Math.pow(X[i] - p2, 2);
		}
		
		System.out.println(Math.min(ans1, ans2));
		

	}
}


