import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	}
} Main public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	} 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 double sum = 0; sum 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 avr = sum/N; avr sum/N sum N avr = Math.round(avr) avr Math.round(avr) Math.round Math avr int r = 0; r 0 for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			r += (X[i] - avr) * (X[i] - avr);
		} {
			r += (X[i] - avr) * (X[i] - avr);
		} r += (X[i] - avr) * (X[i] - avr) r (X[i] - avr) * (X[i] - avr) (X[i] - avr) X[i] X i avr (X[i] - avr) X[i] X i avr System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	}
} public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		double sum = 0;
		for(int i = 0; i < N; i++){
			X[i] = sc.nextInt();
			sum += X[i];
		}
		double avr = sum/N;
		avr = Math.round(avr);
		int r = 0;
		for(int i = 0; i < N; i++) {
			r += (X[i] - avr) * (X[i] - avr);
		}
		System.out.println(r);
	}
} Main
import java.util.*;


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