import java.util.*;

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

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    }

    private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    }
} 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[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    }

    private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] people = new int[n]; people new int[n] n int minPosition = 100; minPosition 100 int maxPosition = 1; maxPosition 1 for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        } {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        } int val = sc.nextInt(); val sc.nextInt() sc.nextInt sc minPosition = Math.min(minPosition, val) minPosition Math.min(minPosition, val) Math.min Math minPosition val maxPosition = Math.max(maxPosition, val) maxPosition Math.max(maxPosition, val) Math.max Math maxPosition val people[i] = val people[i] people i val int minValue = Integer.MAX_VALUE; minValue Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        } int p = minPosition; int p = minPosition; p minPosition p <= maxPosition p maxPosition p++ p++ p {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        } {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        } int val = 0; val 0 for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                val += stamina(people[i], p);
            } {
                val += stamina(people[i], p);
            } val += stamina(people[i], p) val stamina(people[i], p) stamina people[i] people i p minValue = Math.min(minValue, val) minValue Math.min(minValue, val) Math.min Math minValue val System.out.println(minValue) System.out.println System.out System System.out minValue String[] args args private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    } stamina {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    } return (int) Math.pow(personStamina - meetingIndex, 2); (int) Math.pow(personStamina - meetingIndex, 2) Math.pow Math personStamina - meetingIndex personStamina meetingIndex 2 int personStamina personStamina int meetingIndex meetingIndex public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    }

    private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    }

    private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    }
} Main
import java.util.*;

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

        int[] people = new int[n];

        int minPosition = 100;
        int maxPosition = 1;
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            minPosition = Math.min(minPosition, val);
            maxPosition = Math.max(maxPosition, val);
            people[i] = val;
        }

        int minValue = Integer.MAX_VALUE;
        for (int p = minPosition; p <= maxPosition; p++) {
            int val = 0;
            for (int i = 0; i < n; i++) {
                val += stamina(people[i], p);
            }
            minValue = Math.min(minValue, val);
        }
        System.out.println(minValue);
    }

    private static int stamina(int personStamina, int meetingIndex) {
        return (int) Math.pow(personStamina - meetingIndex, 2);
    }
}
