import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int ninzu = sc.nextInt(); ninzu sc.nextInt() sc.nextInt sc int []loc_human = new int[ninzu]; loc_human new int[ninzu] ninzu for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < ninzu i ninzu i++ i++ i {
            loc_human[i] = sc.nextInt();
        } {
            loc_human[i] = sc.nextInt();
        } loc_human[i] = sc.nextInt() loc_human[i] loc_human i sc.nextInt() sc.nextInt sc Arrays.sort(loc_human) Arrays.sort Arrays loc_human int result = 0; result 0 for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } int i = loc_human[0]; int i = loc_human[0]; i loc_human[0] loc_human 0 i < loc_human[ninzu-1] i loc_human[ninzu-1] loc_human ninzu-1 ninzu 1 i++ i++ i {
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } {
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } int total = 0; total 0 for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            } int l = 0; int l = 0; l 0 l < loc_human.length l loc_human.length loc_human loc_human.length l++ l++ l {
                total += (int)Math.pow(i - loc_human[l], 2);
            } {
                total += (int)Math.pow(i - loc_human[l], 2);
            } total += (int)Math.pow(i - loc_human[l], 2) total (int)Math.pow(i - loc_human[l], 2) Math.pow Math i - loc_human[l] i loc_human[l] loc_human l 2 if (result == 0 || total < result){
                result = total;
            } result == 0 || total < result result == 0 result 0 total < result total result {
                result = total;
            } result = total result total System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu = sc.nextInt();
        int []loc_human = new int[ninzu];
        
        for (int i = 0; i < ninzu; i++){
            loc_human[i] = sc.nextInt();
        }
        
        Arrays.sort(loc_human);
        
        int result = 0;
        
        for (int i = loc_human[0]; i < loc_human[ninzu-1]; i++){
            int total = 0;
            for (int l = 0; l < loc_human.length; l++){
                total += (int)Math.pow(i - loc_human[l], 2);
            }
            
            if (result == 0 || total < result){
                result = total;
            } 
        } 

        System.out.println(result);
    }
}
