import java.util.Arrays;
import java.util.Scanner;

public 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
} 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	} 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	} 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 max = X[N-1]; max X[N-1] X N-1 N 1 int minTotal = Integer.MAX_VALUE; minTotal Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		} int i=min; int i=min; i min i<=max i max i++ i++ i {
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		} {
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		} int total = 0; total 0 for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			} int j=0; int j=0; j 0 j<N j N j++ j++ j {
				total += Math.pow(i - X[j], 2);
			} {
				total += Math.pow(i - X[j], 2);
			} total += Math.pow(i - X[j], 2) total Math.pow(i - X[j], 2) Math.pow Math i - X[j] i X[j] X j 2 minTotal = Math.min(minTotal, total) minTotal Math.min(minTotal, total) Math.min Math minTotal total System.out.println(minTotal) System.out.println System.out System System.out minTotal String[] args args public 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
} public 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public 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 max = X[N-1];
		
		int minTotal = Integer.MAX_VALUE;
		for (int i=min; i<=max; i++){
			int total = 0;
			for (int j=0; j<N; j++){
				total += Math.pow(i - X[j], 2);
			}
			minTotal = Math.min(minTotal, total);
		}
		System.out.println(minTotal);
	}
}