import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br Long a[] = new Long[n]; a new Long[n] n String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			a[i] = Long.parseLong(str[i]);
		} {
			a[i] = Long.parseLong(str[i]);
		} a[i] = Long.parseLong(str[i]) a[i] a i Long.parseLong(str[i]) Long.parseLong Long str[i] str i long ans = Long.MAX_VALUE; ans Long.MAX_VALUE Long Long.MAX_VALUE for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		} {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		} long cost = 0; cost 0 for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				cost += Math.pow(a[j] - i, 2);
			} {
				cost += Math.pow(a[j] - i, 2);
			} cost += Math.pow(a[j] - i, 2) cost Math.pow(a[j] - i, 2) Math.pow Math a[j] - i a[j] a j i 2 ans = Math.min(ans, cost) ans Math.min(ans, cost) Math.min Math ans cost System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		Long a[] = new Long[n];

		String str[] = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);
		}

		long ans = Long.MAX_VALUE;
		for (int i = 0; i <= 100; i++) {
			long cost = 0;

			for (int j = 0; j < n; j++) {
				cost += Math.pow(a[j] - i, 2);
			}
			ans = Math.min(ans, cost);
		}

		System.out.println(ans);
	}
}