import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	} main {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] x = new int[n]; x new int[n] n int max = 0; max 0 int min = 100; min 100 for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		} {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		} x[i] = stdIn.nextInt() x[i] x i stdIn.nextInt() stdIn.nextInt stdIn max = Math.max(max, x[i]) max Math.max(max, x[i]) Math.max Math max x[i] x i min = Math.min(min, x[i]) min Math.min(min, x[i]) Math.min Math min x[i] x i int cost = Integer.MAX_VALUE; cost Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		} int i = min; int i = min; i min i<=max i max i++ i++ i {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		} {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		} int ans = 0; ans 0 for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				ans = ans + ((x[j]-i)*(x[j]-i));
			} {
				ans = ans + ((x[j]-i)*(x[j]-i));
			} ans = ans + ((x[j]-i)*(x[j]-i)) ans ans + ((x[j]-i)*(x[j]-i)) ans ((x[j]-i)*(x[j]-i)) (x[j]-i) x[j] x j i (x[j]-i) x[j] x j i cost = Math.min(cost, ans) cost Math.min(cost, ans) Math.min Math cost ans System.out.println(cost) System.out.println System.out System System.out cost String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int max = 0;
		int min = 100;

		for(int i = 0;i < n;i++) {
			x[i] = stdIn.nextInt();
			max = Math.max(max, x[i]);
			min = Math.min(min, x[i]);
		}


		int cost = Integer.MAX_VALUE;

		for(int i = min;i<=max;i++) {
			int ans = 0;
			for(int j = 0;j < n;j++) {
				ans = ans + ((x[j]-i)*(x[j]-i));
			}
			cost = Math.min(cost, ans);
		}

		System.out.println(cost);

	}

}
