import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 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 int[] place = new int[N]; place new int[N] N double sum = 0; sum 0 for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            place[i] = sc.nextInt();
            sum += place[i];
        } {
            place[i] = sc.nextInt();
            sum += place[i];
        } place[i] = sc.nextInt() place[i] place i sc.nextInt() sc.nextInt sc sum += place[i] sum place[i] place i double av = sum / N; av sum / N sum N int intav = (int)av; intav (int)av if(av - intav >= 0.5) {
            intav += 1;
        } av - intav >= 0.5 av - intav av intav 0.5 {
            intav += 1;
        } intav += 1 intav 1 int ans = 0; ans 0 for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            ans += Math.pow(place[i] - intav, 2);
        } {
            ans += Math.pow(place[i] - intav, 2);
        } ans += Math.pow(place[i] - intav, 2) ans Math.pow(place[i] - intav, 2) Math.pow Math place[i] - intav place[i] place i intav 2 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) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] place = new int[N];
        double sum = 0;
        
        
        for(int i = 0; i < N; i++) {
            place[i] = sc.nextInt();
            sum += place[i];
        }
        
        double av = sum / N;
        int intav = (int)av;
        if(av - intav >= 0.5) {
            intav += 1;
        }
        

        int ans = 0;
        for(int i = 0; i < N; i++) {
            ans += Math.pow(place[i] - intav, 2);
        }
        
        System.out.println(ans);
        
    }
}