import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
} Main public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    } main {
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    } final Scanner sc = new Scanner(System.in); sc new Scanner(System.in) final int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc final int[] X = new int[n]; X new int[n] n for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            X[i] = sc.nextInt();
        } {
            X[i] = sc.nextInt();
        } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc sc.close() sc.close sc Arrays.sort(X) Arrays.sort Arrays X int sum = 0 sum 0 min = 0; min 0 for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
            min += Math.pow(X[0] - X[j],2);
        } {
            min += Math.pow(X[0] - X[j],2);
        } min += Math.pow(X[0] - X[j],2) min Math.pow(X[0] - X[j],2) Math.pow Math X[0] - X[j] X[0] X 0 X[j] X j 2 for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        } int i = X[0] + 1; int i = X[0] + 1; i X[0] + 1 X[0] X 0 1 i < X[n-1] i X[n-1] X n-1 n 1 i++ i++ i {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        } {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        } sum = 0 sum 0 for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                sum += Math.pow(i - X[j],2);
            } {
                sum += Math.pow(i - X[j],2);
            } sum += Math.pow(i - X[j],2) sum Math.pow(i - X[j],2) Math.pow Math i - X[j] i X[j] X j 2 if(min == -1 ||sum < min)
                min = sum; min == -1 ||sum < min min == -1 min -1 1 sum < min sum min min = sum min sum System.out.println(min) System.out.println System.out System System.out min final String[] args args public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
} Main
import java.util.*;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        final int n = sc.nextInt();
        final int[] X = new int[n];
        
        for (int i = 0; i < n; i++) {
            X[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(X);
        int sum = 0, min = 0;
        for (int j = 0; j < n; j++) {
            min += Math.pow(X[0] - X[j],2);
        }
        for (int i = X[0] + 1; i < X[n-1]; i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += Math.pow(i - X[j],2);
            }
            if(min == -1 ||sum < min)
                min = sum;
        }
        System.out.println(min);
    }
}