import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

} import java.util.*; util.* java public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int MOD = 1000000007; MOD 1000000007 final int MAX = Integer.MAX_VALUE; MAX Integer.MAX_VALUE Integer Integer.MAX_VALUE final long LMAX = Long.MAX_VALUE; LMAX Long.MAX_VALUE Long Long.MAX_VALUE int LEN = (int)1e6 + 1; LEN (int)1e6 + 1 (int)1e6 1 void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	} doIt {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	} 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 int sum = 0; sum 0 for(int i = 0; i < N; i++) {
			sum += X[i];
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			sum += X[i];
		} {
			sum += X[i];
		} sum += X[i] sum X[i] X i int avg = (int)Math.round((double)sum / N); avg (int)Math.round((double)sum / N) Math.round Math (double)sum / N (double)sum N sum = 0 sum 0 for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			sum += (X[i] - avg) * (X[i] - avg);
		} {
			sum += (X[i] - avg) * (X[i] - avg);
		} sum += (X[i] - avg) * (X[i] - avg) sum (X[i] - avg) * (X[i] - avg) (X[i] - avg) X[i] X i avg (X[i] - avg) X[i] X i avg System.out.println(sum) System.out.println System.out System System.out sum public static void main(String[] args) {
		new Main().doIt();
	} main {
		new Main().doIt();
	} new Main().doIt() new Main().doIt new Main() String[] args args public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

} public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

} Main
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int LEN = (int)1e6 + 1;
	void doIt() {
		int N = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		/*int min = MAX;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) {
				sum += (X[j] - i) * (X[j] - i);
			}
			min = Math.min(min, sum);
		}
		System.out.println(min);*/
		int sum = 0;
		for(int i = 0; i < N; i++) {
			sum += X[i];
		}
		int avg = (int)Math.round((double)sum / N);
		sum = 0;
		for(int i = 0; i < N; i++) {
			sum += (X[i] - avg) * (X[i] - avg);
		}
		System.out.println(sum);
		
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

}
