import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
} Main public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	} main {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = Integer.parseInt(scanner.nextLine()); n Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner int l = 100; l 100 int r = 0; r 0 int a = Integer.MAX_VALUE; a Integer.MAX_VALUE Integer Integer.MAX_VALUE String[] tmp = scanner.nextLine().split(" "); tmp scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " int[] list = new int[n]; list new int[n] n for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		} {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		} list[i] = Integer.parseInt(tmp[i]) list[i] list i Integer.parseInt(tmp[i]) Integer.parseInt Integer tmp[i] tmp i l = Math.min(l,list[i]) l Math.min(l,list[i]) Math.min Math l list[i] list i r = Math.max(r,list[i]) r Math.max(r,list[i]) Math.max Math r list[i] list i int now = 0; now 0 for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		} int i = l; int i = l; i l i <= r i r i++ i++ i {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		} {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		} now = 0 now 0 for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {

				now += (list[j] - i) *  (list[j] - i);

			} {

				now += (list[j] - i) *  (list[j] - i);

			} now += (list[j] - i) *  (list[j] - i) now (list[j] - i) *  (list[j] - i) (list[j] - i) list[j] list j i (list[j] - i) list[j] list j i a = Math.min(a, now) a Math.min(a, now) Math.min Math a now System.out.println(a) System.out.println System.out System System.out a String[] args args public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
} public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		int l = 100;
		int r = 0;
		int a = Integer.MAX_VALUE;
		String[] tmp = scanner.nextLine().split(" ");
		int[] list = new int[n];


		for(int i = 0; i < n; i++) {

			list[i] = Integer.parseInt(tmp[i]);

			l = Math.min(l,list[i]);
			r = Math.max(r,list[i]);

		}

		int now = 0;

		for(int i = l; i <= r ; i++) {

			now = 0;

			for(int j = 0; j < n; j++) {

				now += (list[j] - i) *  (list[j] - i);

			}

			a = Math.min(a, now);

		}

		System.out.println(a);

	}
}