public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
} public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
} Main public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	} main {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	} java.util.Scanner sc = new java.util.Scanner(System.in); sc new java.util.Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] x = new int[n]; x new int[n] n double sum = 0; sum 0 int total = 0; total 0 for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = sc.nextInt();
			sum += x[i];
		} {
			x[i] = sc.nextInt();
			sum += x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i double val = sum / n; val sum / n sum n val = Math.round(val) val Math.round(val) Math.round Math val int avg = (int)val; avg (int)val for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int num = avg - x[i];
			num = num * num;
			total += num;
		} {
			int num = avg - x[i];
			num = num * num;
			total += num;
		} int num = avg - x[i]; num avg - x[i] avg x[i] x i num = num * num num num * num num num total += num total num System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
} public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
} Main
public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		double sum = 0;
		int total = 0;
		
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		double val = sum / n;
		val = Math.round(val);
		int avg = (int)val;
		

		for(int i = 0; i < n; i++) {
			int num = avg - x[i];
			num = num * num;
			total += num;
		}
		
		System.out.println(total);
	}
}
