import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	} main {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int[] x = new int[n]; x new int[n] n int ave = 0; ave 0 for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = stdIn.nextInt();
			ave += x[i];
		} {
			x[i] = stdIn.nextInt();
			ave += x[i];
		} x[i] = stdIn.nextInt() x[i] x i stdIn.nextInt() stdIn.nextInt stdIn ave += x[i] ave x[i] x i ave = (int)Math.round((double)ave/n) ave (int)Math.round((double)ave/n) Math.round Math (double)ave/n (double)ave n int sum = 0; sum 0 for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			sum += (x[i]-(ave))*(x[i]-(ave));
		} {
			sum += (x[i]-(ave))*(x[i]-(ave));
		} sum += (x[i]-(ave))*(x[i]-(ave)) sum (x[i]-(ave))*(x[i]-(ave)) (x[i]-(ave)) x[i] x i (ave) (x[i]-(ave)) x[i] x i (ave) System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	}

} public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] x = new int[n];
		
		
		int ave = 0;
		for(int i = 0; i < n; i++) {
			x[i] = stdIn.nextInt();
			ave += x[i];
		}
		
		ave = (int)Math.round((double)ave/n);
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			sum += (x[i]-(ave))*(x[i]-(ave));
		}
		System.out.println(sum);
		
	}

}
