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 sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
} 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 sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		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 sum = 0; sum 0 for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			x[i] = sc.nextInt();
			sum += x[i];
		} {
			x[i] = sc.nextInt();
			sum += x[i];
		} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i int p = sum / n; p sum / n sum n int p2 = sum / n + 1; p2 sum / n + 1 sum / n sum n 1 int ans = 0; ans 0 int ans2 = 0; ans2 0 for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		} {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		} ans += (x[i] - p) * (x[i] - p) ans (x[i] - p) * (x[i] - p) (x[i] - p) x[i] x i p (x[i] - p) x[i] x i p ans2 += (x[i] - p2) * (x[i] - p2) ans2 (x[i] - p2) * (x[i] - p2) (x[i] - p2) x[i] x i p2 (x[i] - p2) x[i] x i p2 if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		} ans < ans2 ans ans2 {
			System.out.println(ans);
		} System.out.println(ans) System.out.println System.out System System.out ans {
			System.out.println(ans2);
		} System.out.println(ans2) System.out.println System.out System System.out ans2 sc.close() sc.close sc 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];
		int sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
} 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 sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
} Main
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 sum = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			sum += x[i];
		}
		int p = sum / n;
		int p2 = sum / n + 1;
		int ans = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			ans += (x[i] - p) * (x[i] - p);
			ans2 += (x[i] - p2) * (x[i] - p2);
		}
		if (ans < ans2) {
			System.out.println(ans);
		} else {
			System.out.println(ans2);
		}
		sc.close();
	}
}