import java.util.HashMap;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
} import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util public class Main
{
	public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
} Main public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	} main {
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	} HashMap mMap = new HashMap(); mMap new HashMap() Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan int n = Integer.parseInt(str); n Integer.parseInt(str) Integer.parseInt Integer str str = scan.nextLine() str scan.nextLine() scan.nextLine scan String[] substr = str.split(" ", 0); substr str.split(" ", 0) str.split str " " 0 int min = 100; min 100 int max = 1; max 1 for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		} {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		} int target = Integer.parseInt(substr[i]); target Integer.parseInt(substr[i]) Integer.parseInt Integer substr[i] substr i if (target > max) {
				max = target;
			} target > max target max {
				max = target;
			} max = target max target if (target < min) {
				min = target;
			} target < min target min {
				min = target;
			} min = target min target int ans = 0; ans 0 int buf = 0; buf 0 for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        } int i = min; int i = min; i min i < max i max i++ i++ i {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        } {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        } buf = 0 buf 0 for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            } int j=0; int j=0; j 0 j<n j n j++ j++ j {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            } {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            } int target = Integer.parseInt(substr[j]); target Integer.parseInt(substr[j]) Integer.parseInt Integer substr[j] substr j buf = buf + (target  - i) * (target  - i) buf buf + (target  - i) * (target  - i) buf (target  - i) * (target  - i) (target  - i) target i (target  - i) target i if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	} ans == 0 ans 0 {
        		ans = buf;
        	} ans = buf ans buf if (ans > buf) {
        		ans = buf;
        	} ans > buf ans buf {
        		ans = buf;
        	} ans = buf ans buf scan.close() scan.close scan 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)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
} public class Main
{
	public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
} Main
import java.util.HashMap;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		HashMap mMap = new HashMap();
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int n = Integer.parseInt(str);

		str = scan.nextLine();
		String[] substr = str.split(" ", 0);

        int min = 100;
        int max = 1;
		for (int i=0; i<n; i++) {
			int target = Integer.parseInt(substr[i]);
			if (target > max) {
				max = target;
			}
			if (target < min) {
				min = target;
			}
		}


        int ans = 0;
        int buf = 0;
        for (int i = min; i < max; i++) {
        	buf = 0;
    		for (int j=0; j<n; j++) {
    			int target = Integer.parseInt(substr[j]);
            	buf = buf + (target  - i) * (target  - i);
            }
        	if (ans == 0) {
        		ans = buf;
        	} else if (ans > buf) {
        		ans = buf;
        	}

        }
		scan.close();
		System.out.println(ans);
	}
}