import java.util.*;

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

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    }

    // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    }
} import java.util.*; util.* java public class Main {
	public static void main(final String[] args) {

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    }

    // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    }
} Main public static void main(final String[] args) {

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    } main {

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = Integer.parseInt(sc.nextLine()); num Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc Integer[] point = convertString(sc.nextLine(), num); point convertString(sc.nextLine(), num) convertString sc.nextLine() sc.nextLine sc num int minPoint = 100; minPoint 100 int maxPoint = 1; maxPoint 1 int minSum = 1000000; minSum 1000000 for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        } final int i point {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        } {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        } if (i < minPoint) {

                minPoint = i;
            } i < minPoint i minPoint {

                minPoint = i;
            } minPoint = i minPoint i if (i > maxPoint) {

                maxPoint = i;
            } i > maxPoint i maxPoint {

                maxPoint = i;
            } maxPoint = i maxPoint i for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        } int i = minPoint; int i = minPoint; i minPoint i <= maxPoint i maxPoint i++ i++ i {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        } {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        } int sum = 0; sum 0 for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            } int j = 0; int j = 0; j 0 j < point.length j point.length point point.length j++ j++ j {

                sum += Math.pow(point[j] - i, 2);
            } {

                sum += Math.pow(point[j] - i, 2);
            } sum += Math.pow(point[j] - i, 2) sum Math.pow(point[j] - i, 2) Math.pow Math point[j] - i point[j] point j i 2 if (sum < minSum) {

                minSum = sum;
            } sum < minSum sum minSum {

                minSum = sum;
            } minSum = sum minSum sum System.out.println(minSum) System.out.println System.out System System.out minSum final String[] args args // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    } convertString {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    } String[] numStrCol = text.split(" "); numStrCol text.split(" ") text.split text " " Integer[] numCol = new Integer[num]; numCol new Integer[num] num for (int i = 0; i < num; i++) {

            numCol[i] = Integer.parseInt(numStrCol[i]);
        } int i = 0; int i = 0; i 0 i < num i num i++ i++ i {

            numCol[i] = Integer.parseInt(numStrCol[i]);
        } {

            numCol[i] = Integer.parseInt(numStrCol[i]);
        } numCol[i] = Integer.parseInt(numStrCol[i]) numCol[i] numCol i Integer.parseInt(numStrCol[i]) Integer.parseInt Integer numStrCol[i] numStrCol i return numCol; numCol String text text Integer num num public class Main {
	public static void main(final String[] args) {

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    }

    // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    }
} public class Main {
	public static void main(final String[] args) {

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    }

    // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    }
} Main
import java.util.*;

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

        final Scanner sc = new Scanner(System.in);

        // 人数
        int num = Integer.parseInt(sc.nextLine());
        // 住人の座標
        Integer[] point = convertString(sc.nextLine(), num);
        // 住人の座標の最小値・最大値
        int minPoint = 100;
        int maxPoint = 1;
        // 総和の最小値
        int minSum = 1000000;

        // 住人の座標の最小値・最大値取得
        for (final int i : point) {

            if (i < minPoint) {

                minPoint = i;
            }

            if (i > maxPoint) {

                maxPoint = i;
            }
        }

        // 住人の座標の最小値～最大値の間で総和を計算
        for (int i = minPoint; i <= maxPoint; i++) {

            int sum = 0;

            for (int j = 0; j < point.length; j++) {

                sum += Math.pow(point[j] - i, 2);
            }

            if (sum < minSum) {

                minSum = sum;
            }
        }

        // 出力
        System.out.println(minSum);
    }

    // String配列をInteger配列に変換
    private static Integer[] convertString(String text, Integer num) {

        String[] numStrCol = text.split(" ");
        Integer[] numCol = new Integer[num];

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

            numCol[i] = Integer.parseInt(numStrCol[i]);
        }

        return numCol;
    }
}