import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	} main {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int x[] = new int[N]; x new int[N] N for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			x[i] = scan.nextInt();
		} {
			x[i] = scan.nextInt();
		} x[i] = scan.nextInt() x[i] x i scan.nextInt() scan.nextInt scan int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		} int j = 1; int j = 1; j 1 j <= 100 j 100 j++ j++ j {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		} {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		} int cost = 0; cost 0 for (int i : x) {
				cost += (i - j) * (i - j);
			} int i x {
				cost += (i - j) * (i - j);
			} {
				cost += (i - j) * (i - j);
			} cost += (i - j) * (i - j) cost (i - j) * (i - j) (i - j) i j (i - j) i j ans = Math.min(ans, cost) ans Math.min(ans, cost) Math.min Math ans cost 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 scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int x[] = new int[N];

		for (int i = 0; i < N; i++) {
			x[i] = scan.nextInt();
		}

		int ans = Integer.MAX_VALUE;

		for (int j = 1; j <= 100; j++) {
			
			int cost = 0;
			
			for (int i : x) {
				cost += (i - j) * (i - j);
			}
			ans = Math.min(ans, cost);
		}
		System.out.println(ans);
	}
}