import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    }

} Main public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    } main {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    } Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scanner new Scanner(new BufferedReader(new InputStreamReader(System.in))) String n = scanner.nextLine(); n scanner.nextLine() scanner.nextLine scanner String x = scanner.nextLine(); x scanner.nextLine() scanner.nextLine scanner String[] coordinates = x.split(" "); coordinates x.split(" ") x.split x " " int[] numbers = new int[coordinates.length]; numbers new int[coordinates.length] coordinates.length coordinates coordinates.length int min = Integer.parseInt(coordinates[0]); min Integer.parseInt(coordinates[0]) Integer.parseInt Integer coordinates[0] coordinates 0 int max = Integer.parseInt(coordinates[0]); max Integer.parseInt(coordinates[0]) Integer.parseInt Integer coordinates[0] coordinates 0 for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        } int i = 0; int i = 0; i 0 i < coordinates.length i coordinates.length coordinates coordinates.length i++ i++ i {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        } {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        } numbers[i] = Integer.parseInt(coordinates[i]) numbers[i] numbers i Integer.parseInt(coordinates[i]) Integer.parseInt Integer coordinates[i] coordinates i if (numbers[i] > max) {
                max = numbers[i];
            } numbers[i] > max numbers[i] numbers i max {
                max = numbers[i];
            } max = numbers[i] max numbers[i] numbers i if (numbers[i] < min) {
                min = numbers[i];
            } numbers[i] < min numbers[i] numbers i min {
                min = numbers[i];
            } min = numbers[i] min numbers[i] numbers i int minStamina = 1000000; minStamina 1000000 for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        } int i = min; int i = min; i min i <= max i max i++ i++ i {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        } {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        } int stamina = 0; stamina 0 for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            } int j numbers {
                stamina += Math.pow((j-i), 2);
            } {
                stamina += Math.pow((j-i), 2);
            } stamina += Math.pow((j-i), 2) stamina Math.pow((j-i), 2) Math.pow Math (j-i) j i 2 if (stamina < minStamina) {
                minStamina = stamina;
            } stamina < minStamina stamina minStamina {
                minStamina = stamina;
            } minStamina = stamina minStamina stamina System.out.println(minStamina) System.out.println System.out System System.out minStamina String args[] args public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    }

} public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String n = scanner.nextLine();
        String x = scanner.nextLine();
        String[] coordinates = x.split(" ");
        int[] numbers = new int[coordinates.length];

        int min = Integer.parseInt(coordinates[0]);
        int max = Integer.parseInt(coordinates[0]);
        for (int i = 0; i < coordinates.length; i++) {
            numbers[i] = Integer.parseInt(coordinates[i]);
            if (numbers[i] > max) {
                max = numbers[i];
            }
            if (numbers[i] < min) {
                min = numbers[i];
            }
        }

        int minStamina = 1000000;
        for (int i = min; i <= max; i++) {
            int stamina = 0;
            for (int j: numbers) {
                stamina += Math.pow((j-i), 2);
            }
            if (stamina < minStamina) {
                minStamina = stamina;
            }
        }
        System.out.println(minStamina);

    }

}
