import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	}

} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	}

} Main final static long MOD = 1000000007; MOD 1000000007 public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	} main {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String W = in.readLine(); W in.readLine() in.readLine in String[] Ws = W.split(" "); Ws W.split(" ") W.split W " " int N = Integer.parseInt(Ws[0]); N Integer.parseInt(Ws[0]) Integer.parseInt Integer Ws[0] Ws 0 W = in.readLine() W in.readLine() in.readLine in Ws = W.split(" ") Ws W.split(" ") W.split W " " int[] X = new int[N]; X new int[N] N for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			X[i] = Integer.parseInt(Ws[i]);
		} {
			X[i] = Integer.parseInt(Ws[i]);
		} X[i] = Integer.parseInt(Ws[i]) X[i] X i Integer.parseInt(Ws[i]) Integer.parseInt Integer Ws[i] Ws i Arrays.sort(X) Arrays.sort Arrays X long ans = Long.MAX_VALUE; ans Long.MAX_VALUE Long Long.MAX_VALUE long st = X[0]; st X[0] X 0 long ed = X[X.length-1]; ed X[X.length-1] X X.length-1 X.length X X.length 1 for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		} long i=st; long i=st; i st i<=ed i ed i++ i++ i {
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		} {
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		} long tmp=0; tmp 0 for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			} int k=0; int k=0; k 0 k<N k N k++ k++ k {
				tmp+=Math.pow(X[k]-i, 2);
			} {
				tmp+=Math.pow(X[k]-i, 2);
			} tmp+=Math.pow(X[k]-i, 2) tmp Math.pow(X[k]-i, 2) Math.pow Math X[k]-i X[k] X k i 2 ans = Math.min(ans, tmp) ans Math.min(ans, tmp) Math.min Math ans tmp System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	}

} public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	}

} Main
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);

		W = in.readLine();
		Ws = W.split(" ");
		int[] X = new int[N];
		for(int i=0;i<N;i++){
			X[i] = Integer.parseInt(Ws[i]);
		}

		Arrays.sort(X);

		long ans = Long.MAX_VALUE;

		long st = X[0];
		long ed = X[X.length-1];
		for(long i=st;i<=ed;i++){
			long tmp=0;
			for(int k=0;k<N;k++){
				tmp+=Math.pow(X[k]-i, 2);
			}
			ans = Math.min(ans, tmp);
		}

		System.out.println(ans);

	}

}
