import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections 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[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] list = new int[N]; list new int[N] N for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			list[i] = sc.nextInt();
		} {
			list[i] = sc.nextInt();
		} list[i] = sc.nextInt() list[i] list i sc.nextInt() sc.nextInt sc Arrays.sort(list) Arrays.sort Arrays list ArrayList<Integer> array = new ArrayList<Integer>(); array new ArrayList<Integer>() for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		} int i = list[0]; int i = list[0]; i list[0] list 0 i <= list[N - 1] i list[N - 1] list N - 1 N 1 i++ i++ i {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		} {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		} int serve = 0; serve 0 for (int p : list) {
				serve += (p - i) * (p - i);
			} int p list {
				serve += (p - i) * (p - i);
			} {
				serve += (p - i) * (p - i);
			} serve += (p - i) * (p - i) serve (p - i) * (p - i) (p - i) p i (p - i) p i array.add(serve) array.add array serve Collections.sort(array) Collections.sort Collections array System.out.println(array.get(0)) System.out.println System.out System System.out array.get(0) array.get array 0 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	}
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list);
		ArrayList<Integer> array = new ArrayList<Integer>();

		for (int i = list[0]; i <= list[N - 1]; i++) {
			int serve = 0;
			for (int p : list) {
				serve += (p - i) * (p - i);
			}
			array.add(serve);
		}

		Collections.sort(array);
		System.out.println(array.get(0));
	}
}