import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	} 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 int total = 0; total 0 double intaverage intaverage doubleaverage; doubleaverage int finalaverage; finalaverage int minvalue = 0; minvalue 0 for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = sc.nextInt();
			total += x[i];
		} {
			x[i] = sc.nextInt();
			total += x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc total += x[i] total x[i] x i intaverage = total / n intaverage total / n total n doubleaverage = (double)total/n doubleaverage (double)total/n (double)total n if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		} intaverage + 0.5 < doubleaverage intaverage + 0.5 intaverage 0.5 doubleaverage {
			finalaverage = (int)intaverage + 1;
		} finalaverage = (int)intaverage + 1 finalaverage (int)intaverage + 1 (int)intaverage 1 {
			finalaverage = (int)intaverage;
		} finalaverage = (int)intaverage finalaverage (int)intaverage for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		} {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		} if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			} minvalue > x[i] minvalue x[i] x i {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			} minvalue += (int)Math.pow(finalaverage-x[i], 2) minvalue (int)Math.pow(finalaverage-x[i], 2) Math.pow Math finalaverage-x[i] finalaverage x[i] x i 2 {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			} minvalue += (int)Math.pow(x[i]-finalaverage, 2) minvalue (int)Math.pow(x[i]-finalaverage, 2) Math.pow Math x[i]-finalaverage x[i] x i finalaverage 2 System.out.println(minvalue) System.out.println System.out System System.out minvalue String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

}