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 = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		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 sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] livePoint = new int[n]; livePoint new int[n] n for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			livePoint[i] = Integer.parseInt(sc.next());
		} {
			livePoint[i] = Integer.parseInt(sc.next());
		} livePoint[i] = Integer.parseInt(sc.next()) livePoint[i] livePoint i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Arrays.sort(livePoint) Arrays.sort Arrays livePoint int min = -1; min -1 1 for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		} int i = livePoint[0]; int i = livePoint[0]; i livePoint[0] livePoint 0 i <= livePoint[n - 1] i livePoint[n - 1] livePoint n - 1 n 1 i++ i++ i {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		} {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		} int total = 0; total 0 for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				total += (int) Math.pow(i - livePoint[j], 2);
			} {
				total += (int) Math.pow(i - livePoint[j], 2);
			} total += (int) Math.pow(i - livePoint[j], 2) total (int) Math.pow(i - livePoint[j], 2) Math.pow Math i - livePoint[j] i livePoint[j] livePoint j 2 if (min == -1 || total < min) {
				min = total;
			} min == -1 || total < min min == -1 min -1 1 total < min total min {
				min = total;
			} min = total min total 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 sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	}

} 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 = Integer.parseInt(sc.next());
		int[] livePoint = new int[n];
		for (int i = 0; i < n; i++) {
			livePoint[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(livePoint);
		int min = -1;
		for (int i = livePoint[0]; i <= livePoint[n - 1]; i++) {
			int total = 0;
			for (int j = 0; j < n; j++) {
				total += (int) Math.pow(i - livePoint[j], 2);
			}
			if (min == -1 || total < min) {
				min = total;
			}
		}
		System.out.println(min);
	}

}
