
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 allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	}
} 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 allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int[] x= new int[n];
		double allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int[] x= new int[n];
		double allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	} 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 allx=0; allx 0 double allx2=0; allx2 0 for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		} {
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc allx+=x[i] allx x[i] x i allx2+=x[i]*x[i] allx2 x[i]*x[i] x[i] x i x[i] x i int p; p if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		} allx/n-(int)(allx/n)<0.5 allx/n-(int)(allx/n) allx/n allx n (int)(allx/n) allx n 0.5 {
			p=(int)(allx/n);
		} p=(int)(allx/n) p (int)(allx/n) allx n {
			p=(int)(allx/n)+1;
		} p=(int)(allx/n)+1 p (int)(allx/n)+1 (int)(allx/n) allx n 1 System.out.println((int)(allx2-2*allx*p+n*p*p)) System.out.println System.out System System.out (int)(allx2-2*allx*p+n*p*p) allx2-2*allx*p allx2 2*allx*p 2*allx*p 2 allx p n*p*p n*p*p n p p 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 allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	}
} 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 allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	}
} 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 allx=0;
		double allx2=0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
			allx+=x[i];
			allx2+=x[i]*x[i];
		}
		int p;
		if(allx/n-(int)(allx/n)<0.5){
			p=(int)(allx/n);
		}else{
			p=(int)(allx/n)+1;
		}
	System.out.println((int)(allx2-2*allx*p+n*p*p));
	}
}