import java.lang.Math;
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();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    }
}  import java.lang.Math; Math java.lang 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();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    }
} 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();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    } 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();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    } 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 Arrays.sort(X) Arrays.sort Arrays X int min = X[0]; min X[0] X 0 int P = min; P min int Sum = 1000000000; Sum 1000000000 while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        } true {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        } int sum = 0; sum 0 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 P++ P if (Sum < sum) break; Sum < sum Sum sum break; Sum = sum Sum sum System.out.println(Sum) System.out.println System.out System System.out Sum String[] args args
import java.lang.Math;
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();
        }
        Arrays.sort(X);
        int min = X[0];
        int P = min;
        int Sum = 1000000000;
        while (true) {
        		int sum = 0;
        		for (int i=0; i<N; i++) {
        			sum += Math.pow(X[i]-P, 2);
        		}
        		P++;
        		if (Sum < sum) break;
        		Sum = sum;
        }
        System.out.println(Sum);
    }
} 