import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        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 ans = 0; ans 0 int hikaku = Integer.MAX_VALUE; hikaku Integer.MAX_VALUE Integer Integer.MAX_VALUE List<Integer> point = new ArrayList<>(); point new ArrayList<>() for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            point.add(sc.nextInt());
        } {
            point.add(sc.nextInt());
        } point.add(sc.nextInt()) point.add point sc.nextInt() sc.nextInt sc Collections.sort(point) Collections.sort Collections point for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        } int i = 1; int i = 1; i 1 i <= point.get(n-1) i point.get(n-1) point.get point n-1 n 1 i++ i++ i {
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        } {
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        } int sum = 0; sum 0 for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                sum += Math.pow(point.get(j)-i,2);
            } {
                sum += Math.pow(point.get(j)-i,2);
            } sum += Math.pow(point.get(j)-i,2) sum Math.pow(point.get(j)-i,2) Math.pow Math point.get(j)-i point.get(j) point.get point j i 2 ans = Math.min(sum,hikaku) ans Math.min(sum,hikaku) Math.min Math sum hikaku if(sum < hikaku)
                hikaku = sum; sum < hikaku sum hikaku hikaku = sum hikaku sum System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int hikaku = Integer.MAX_VALUE;
        List<Integer> point = new ArrayList<>();
        for(int i = 0;i < n;i++){
            point.add(sc.nextInt());
        }
        Collections.sort(point);

        for(int i = 1;i <= point.get(n-1);i++){
            int sum = 0;
            for(int j = 0;j < n;j++){
                sum += Math.pow(point.get(j)-i,2);
            }
            ans = Math.min(sum,hikaku);
            if(sum < hikaku)
                hikaku = sum;
        }

        System.out.println(ans);
    }
}