
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	} main {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int x[]=new int[n]; x new int[n] n for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			x[i]=scan.nextInt();
		} {
			x[i]=scan.nextInt();
		} x[i]=scan.nextInt() x[i] x i scan.nextInt() scan.nextInt scan scan.close() scan.close scan long  min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE Arrays.sort(x) Arrays.sort Arrays x for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		} int i=1; int i=1; i 1 i<=x[n-1] i x[n-1] x n-1 n 1 i++ i++ i {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		} {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		} long sum =0; sum 0 for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			} int j=0; int j=0; j 0 j<n j n j++ j++ j {
				sum += (x[j]-i)* (x[j]-i);
			} {
				sum += (x[j]-i)* (x[j]-i);
			} sum += (x[j]-i)* (x[j]-i) sum (x[j]-i)* (x[j]-i) (x[j]-i) x[j] x j i (x[j]-i) x[j] x j i if(min > sum) min = sum; min > sum min sum min = sum min sum System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
} Main

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x[]=new int[n];
		for(int i=0;i<n;i++) {
			x[i]=scan.nextInt();
		}
		scan.close();
		long  min = Integer.MAX_VALUE;
		Arrays.sort(x);
		for(int i=1; i<=x[n-1];i++) {
			long sum =0;
			for(int j=0;j<n;j++) {
				sum += (x[j]-i)* (x[j]-i);
			}
			if(min > sum) min = sum;
		}
		System.out.println(min);
	}
}
