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 cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	}

} 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 cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	}

} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	} main {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] x = new int[n];
		int cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	} 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 cnt = 0; cnt 0 for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		} {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		} x[i] = stdIn.nextInt() x[i] x i stdIn.nextInt() stdIn.nextInt stdIn cnt += x[i] cnt x[i] x i int a =(int) Math.round((double)cnt/n); a (int) Math.round((double)cnt/n) Math.round Math (double)cnt/n (double)cnt n int ans = 0; ans 0 for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ans += (a-x[i])*(a-x[i]);
		} {
			ans += (a-x[i])*(a-x[i]);
		} ans += (a-x[i])*(a-x[i]) ans (a-x[i])*(a-x[i]) (a-x[i]) a x[i] x i (a-x[i]) a x[i] x i System.out.println(ans) System.out.println System.out System System.out ans 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 cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	}

} 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 cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	}

} 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 cnt = 0;
		for(int i = 0;i < n; i++) {
			x[i] = stdIn.nextInt();
			cnt += x[i];
		}
		int a =(int) Math.round((double)cnt/n);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			ans += (a-x[i])*(a-x[i]);
		}
		System.out.println(ans);
		
	}

}
