import java.util.*;


class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.nextLine();

        double sum = 0;
        int ans = 0;
        double[] list = new double[N];

        for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        }

        int mid = (int) Math.round(sum / N);

        for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        }

        System.out.println(ans);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.nextLine();

        double sum = 0;
        int ans = 0;
        double[] list = new double[N];

        for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        }

        int mid = (int) Math.round(sum / N);

        for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.nextLine();

        double sum = 0;
        int ans = 0;
        double[] list = new double[N];

        for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        }

        int mid = (int) Math.round(sum / N);

        for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.nextLine();

        double sum = 0;
        int ans = 0;
        double[] list = new double[N];

        for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        }

        int mid = (int) Math.round(sum / N);

        for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        }

        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc double sum = 0; sum 0 int ans = 0; ans 0 double[] list = new double[N]; list new double[N] N for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            list[i] = sc.nextDouble();
            sum += list[i];
        } {
            list[i] = sc.nextDouble();
            sum += list[i];
        } list[i] = sc.nextDouble() list[i] list i sc.nextDouble() sc.nextDouble sc sum += list[i] sum list[i] list i int mid = (int) Math.round(sum / N); mid (int) Math.round(sum / N) Math.round Math sum / N sum N for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            ans += Math.pow(list[i]-mid,2);
        } {
            ans += Math.pow(list[i]-mid,2);
        } ans += Math.pow(list[i]-mid,2) ans Math.pow(list[i]-mid,2) Math.pow Math list[i]-mid list[i] list i mid 2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;


class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.nextLine();

        double sum = 0;
        int ans = 0;
        double[] list = new double[N];

        for (int i = 0; i < N; i++) {
            list[i] = sc.nextDouble();
            sum += list[i];
        }

        int mid = (int) Math.round(sum / N);

        for (int i = 0; i < N; i++) {
            ans += Math.pow(list[i]-mid,2);
        }

        System.out.println(ans);
    }
}