import java.util.Scanner;

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

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(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[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] x = new int[n]; x new int[n] n int l = Integer.MAX_VALUE / 2 l Integer.MAX_VALUE / 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE 2 r = -1; r -1 1 for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        } {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc l = Math.min(l, x[i]) l Math.min(l, x[i]) Math.min Math l x[i] x i r = Math.max(r, x[i]) r Math.max(r, x[i]) Math.max Math r x[i] x i long min = Integer.MAX_VALUE / 2; min Integer.MAX_VALUE / 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE 2 for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        } int i = l; int i = l; i l i <= r i r i++ i++ i {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        } {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        } long d = 0; d 0 for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                d += Math.pow(i - x[j], 2);
            } {
                d += Math.pow(i - x[j], 2);
            } d += Math.pow(i - x[j], 2) d Math.pow(i - x[j], 2) Math.pow Math i - x[j] i x[j] x j 2 min = Math.min(min, d) min Math.min(min, d) Math.min Math min d System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(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[] x = new int[n];

        int l = Integer.MAX_VALUE / 2, r = -1;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            l = Math.min(l, x[i]);
            r = Math.max(r, x[i]);
        }
        long min = Integer.MAX_VALUE / 2;
        for (int i = l; i <= r; i++) {
            long d = 0;
            for (int j = 0; j < n; j++) {
                d += Math.pow(i - x[j], 2);
            }
            min = Math.min(min, d);
        }
        System.out.println(min);
    }
}