import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    }

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

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    } main {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) double member = scanner.nextDouble(); member scanner.nextDouble() scanner.nextDouble scanner double[] memberCoordinate = new double[(int) member]; memberCoordinate new double[(int) member] (int) member double sumMemberCoordinate = 0; sumMemberCoordinate 0 for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        } int index = 0; int index = 0; index 0 index < member index member index++ index++ index {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        } {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        } memberCoordinate[index] = scanner.nextDouble() memberCoordinate[index] memberCoordinate index scanner.nextDouble() scanner.nextDouble scanner sumMemberCoordinate += memberCoordinate[index] sumMemberCoordinate memberCoordinate[index] memberCoordinate index scanner.close() scanner.close scanner double meetingCoordinate = Math.round(sumMemberCoordinate / member); meetingCoordinate Math.round(sumMemberCoordinate / member) Math.round Math sumMemberCoordinate / member sumMemberCoordinate member double totalEnergy = 0; totalEnergy 0 for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        } int index = 0; int index = 0; index 0 index < memberCoordinate.length index memberCoordinate.length memberCoordinate memberCoordinate.length index++ index++ index {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        } {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        } totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2) totalEnergy Math.pow(memberCoordinate[index] - meetingCoordinate, 2) Math.pow Math memberCoordinate[index] - meetingCoordinate memberCoordinate[index] memberCoordinate index meetingCoordinate 2 System.out.println((int) totalEnergy) System.out.println System.out System System.out (int) totalEnergy String[] args args public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    }

} public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // 入力データの取得
        Scanner scanner = new Scanner(System.in);
        double member = scanner.nextDouble();
        double[] memberCoordinate = new double[(int) member];
        double sumMemberCoordinate = 0;
        for (int index = 0; index < member; index++) {
            memberCoordinate[index] = scanner.nextDouble();
            sumMemberCoordinate += memberCoordinate[index];
        }
        scanner.close();

        // 処理を行う
        // 最適な座標の算出
        double meetingCoordinate = Math.round(sumMemberCoordinate / member);

        // それぞれの消費体力の算出とその合計値の算出
        double totalEnergy = 0;
        for (int index = 0; index < memberCoordinate.length; index++) {
            totalEnergy += Math.pow(memberCoordinate[index] - meetingCoordinate, 2);
        }

        // 結果の出力
        System.out.println((int) totalEnergy);

    }

}