import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] a = new int[n]; a new int[n] n int max = -1; max -1 1 for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        } {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc if (max < a[i])
                max = a[i]; max < a[i] max a[i] a i max = a[i] max a[i] a i int hp_min = Integer.MAX_VALUE; hp_min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        } int i = 1; int i = 1; i 1 i <= max i max i++ i++ i {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        } {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        } int hp = 0; hp 0 for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            } int j = 0; int j = 0; j 0 j < a.length j a.length a a.length j++ j++ j {
                hp += Math.pow(a[j] - i, 2);
            } {
                hp += Math.pow(a[j] - i, 2);
            } hp += Math.pow(a[j] - i, 2) hp Math.pow(a[j] - i, 2) Math.pow Math a[j] - i a[j] a j i 2 if (hp < hp_min) {
                hp_min = hp;
            } hp < hp_min hp hp_min {
                hp_min = hp;
            } hp_min = hp hp_min hp System.out.println(hp_min) System.out.println System.out System System.out hp_min String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
} Main
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];
        
        int max = -1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

            if (max < a[i])
                max = a[i];
        }

        int hp_min = Integer.MAX_VALUE;
        for (int i = 1; i <= max; i++) {
            int hp = 0;
            for (int j = 0; j < a.length; j++) {
                hp += Math.pow(a[j] - i, 2);
            }
            if (hp < hp_min) {
                hp_min = hp;
            }
        }

        System.out.println(hp_min);
    }
}