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

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 min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - p);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner 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];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - p);
	}
} Main public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	} 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 min = 2000000000; min 2000000000 int h = 0; h 0 for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = sc.nextInt();
		} {
			x[i] = sc.nextInt();
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc Arrays.sort(x) Arrays.sort Arrays x if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		} x[0] == x[x.length - 1] x[0] x 0 x[x.length - 1] x x.length - 1 x.length x x.length 1 {
			System.out.println(0);
			System.exit(0);
		} System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		} int i = x[0]; int i = x[0]; i x[0] x 0 i < x[x.length - 1] i x[x.length - 1] x x.length - 1 x.length x x.length 1 i++ i++ i {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		} {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		} h = 0 h 0 for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			} int value x {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			} {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			} h += cost(value, i) h cost(value, i) cost value i if(h > min) {
					break;
				} h > min h min {
					break;
				} break; if(h < min) min = h; h < min h min min = h min h System.out.println(min) System.out.println System.out System System.out min sc.close() sc.close sc String [] args args public static int cost(int x, int p) {
		return (x - p) * (x - p);
	} cost {
		return (x - p) * (x - p);
	} return (x - p) * (x - p); (x - p) * (x - p) (x - p) x p (x - p) x p int x x int 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];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - 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];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - p);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

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 min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - p);
	}
}