import java.util.*;
import java.lang.Math;


public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
} import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
} Main public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	} main {
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int i i j j k=0 k 0 flag=0 flag 0 v v w=0 w 0 p=0 p 0 r=0; r 0 int n; n double m m q; q n=sc.nextInt() n sc.nextInt() sc.nextInt sc int[] x=new int[n]; x new int[n] n for(i=0;i<n;i++)
			x[i]=sc.nextInt(); i=0; i=0 i 0 i<n i n i++ i++ i x[i]=sc.nextInt(); x[i]=sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc for(i=0;i<n;i++)
			k=k+x[i]; i=0; i=0 i 0 i<n i n i++ i++ i k=k+x[i]; k=k+x[i] k k+x[i] k x[i] x i j=k/n j k/n k n w=k/n+1 w k/n+1 k/n k n 1 v=0 v 0 q=0 q 0 for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		} i=0; i=0 i 0 i<n i n i++ i++ i {
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		} {
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		} m=(double)(j-x[i]) m (double)(j-x[i]) j x[i] x i flag=(int)(Math.pow(m,2.0)) flag (int)(Math.pow(m,2.0)) Math.pow Math m 2.0 v=v+flag v v+flag v flag q=(double)(w-x[i]) q (double)(w-x[i]) w x[i] x i r=(int)(Math.pow(q,2.0)) r (int)(Math.pow(q,2.0)) Math.pow Math q 2.0 p=p+r p p+r p r if(v<p)
			System.out.println(v);
		else
			System.out.println(p); v<p v p System.out.println(v) System.out.println System.out System System.out v System.out.println(p) System.out.println System.out System System.out p String[] args args public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
} public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
} Main
import java.util.*;
import java.lang.Math;


public class Main
{
	
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int i,j,k=0,flag=0,v,w=0,p=0,r=0;
		int n;
		double m,q;
		n=sc.nextInt();
		int[] x=new int[n];
		for(i=0;i<n;i++)
			x[i]=sc.nextInt();
		for(i=0;i<n;i++)
			k=k+x[i];
		j=k/n;
		w=k/n+1;

		v=0;
		q=0;
		for(i=0;i<n;i++)
		{
			m=(double)(j-x[i]);
			flag=(int)(Math.pow(m,2.0));
			v=v+flag;
			q=(double)(w-x[i]);
			r=(int)(Math.pow(q,2.0));
			p=p+r;

		}
		if(v<p)
			System.out.println(v);
		else
			System.out.println(p);

		
		
		
	}
}