//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
} import java.util.*; util.* java import java.math.BigDecimal; BigDecimal java.math public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		} 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 P = 0; P 0 for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		} int i=0; int i=0; i 0 i<N i N i++ i++ i {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		} {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		} X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc P = (P+X[i]) P (P+X[i]) P X[i] X i double avg = (double)P/N; avg (double)P/N (double)P N int zahyou = (int)Math.floor(avg); zahyou (int)Math.floor(avg) Math.floor Math avg int zahyou2 = (int)Math.ceil(avg); zahyou2 (int)Math.ceil(avg) Math.ceil Math avg int souwa = 0; souwa 0 int souwa2 = 0; souwa2 0 for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			} int j=0; int j=0; j 0 j<N j N j++ j++ j {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			} {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			} souwa = (int) (souwa + Math.pow((X[j]-zahyou),2)) souwa (int) (souwa + Math.pow((X[j]-zahyou),2)) souwa Math.pow((X[j]-zahyou),2) Math.pow Math (X[j]-zahyou) X[j] X j zahyou 2 souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2)) souwa2 (int) (souwa2 + Math.pow(X[j]-zahyou2, 2)) souwa2 Math.pow(X[j]-zahyou2, 2) Math.pow Math X[j]-zahyou2 X[j] X j zahyou2 2 System.out.println(Math.min(souwa, souwa2)) System.out.println System.out System System.out Math.min(souwa, souwa2) Math.min Math souwa souwa2 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];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
} public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
} Main
//package atcoder;
 
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int P = 0;
		for(int i=0;i<N;i++) {
			X[i] = sc.nextInt();
			P = (P+X[i]);
		}
		double avg = (double)P/N;
		//System.out.println(avg);
		int zahyou = (int)Math.floor(avg);
		//System.out.println(zahyou);
		int zahyou2 = (int)Math.ceil(avg);
		//System.out.println(zahyou2);

		int souwa = 0;
		int souwa2 = 0;
	
		for(int j=0;j<N;j++) {
			souwa = (int) (souwa + Math.pow((X[j]-zahyou),2));
			souwa2 = (int) (souwa2 + Math.pow(X[j]-zahyou2, 2));
			}
		System.out.println(Math.min(souwa, souwa2));
		}
}