import 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 Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    }
} 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[] X = new int[N];
        int Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        int Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] X = new int[N];
        int Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    } 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 Xmax = 0; Xmax 0 int Xmin = 1000; Xmin 1000 int Xsum = 0; Xsum 0 for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        } int i = 0; int i = 0; i 0 i < N i N i ++ i ++ i {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        } {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc Xsum += X[i] Xsum X[i] X i if (Xmax < X[i]) {
                Xmax = X[i];
            } Xmax < X[i] Xmax X[i] X i {
                Xmax = X[i];
            } Xmax = X[i] Xmax X[i] X i if (X[i] < Xmin) {
                Xmin = X[i];
            } X[i] < Xmin X[i] X i Xmin {
                Xmin = X[i];
            } Xmin = X[i] Xmin X[i] X i sc.close() sc.close sc int P = Xsum / N; P Xsum / N Xsum N int Power1 = 0; Power1 0 int Power2 = 0; Power2 0 for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        } {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        } Power1 += (X[i] - P) * (X[i] - P) Power1 (X[i] - P) * (X[i] - P) (X[i] - P) X[i] X i P (X[i] - P) X[i] X i P Power2 += (X[i] - P - 1) * (X[i] - P - 1) Power2 (X[i] - P - 1) * (X[i] - P - 1) (X[i] - P - 1) X[i] - P - 1 X[i] X i P 1 (X[i] - P - 1) X[i] - P - 1 X[i] X i P 1 System.out.println(Math.min(Power1, Power2)) System.out.println System.out System System.out Math.min(Power1, Power2) Math.min Math Power1 Power2 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 Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    }
} 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 Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    }
} Main
import 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 Xmax = 0;
        int Xmin = 1000;
        int Xsum = 0;
        for (int i = 0; i < N; i ++) {
            X[i] = sc.nextInt();
            Xsum += X[i];
            if (Xmax < X[i]) {
                Xmax = X[i];
            }
            if (X[i] < Xmin) {
                Xmin = X[i];
            }
        }
        sc.close();

        // int P = (Xmin + Xmax) / 2;
        int P = Xsum / N;
        int Power1 = 0;
        int Power2 = 0;
        for (int i = 0; i < N; i++) {
            Power1 += (X[i] - P) * (X[i] - P);
            Power2 += (X[i] - P - 1) * (X[i] - P - 1);
        }

        System.out.println(Math.min(Power1, Power2));
    }
}
