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 sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    }
} 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 sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    } 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 sum = 0; sum 0 for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        } int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
            x[i] = sc.nextInt();
            sum += x[i];
        } {
            x[i] = sc.nextInt();
            sum += x[i];
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sum += x[i] sum x[i] x i int p = sum / n; p sum / n sum n int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        } int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        } {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        } sum1 += Math.pow(p - x[i], 2) sum1 Math.pow(p - x[i], 2) Math.pow Math p - x[i] p x[i] x i 2 sum2 += Math.pow(p + 1 - x[i], 2) sum2 Math.pow(p + 1 - x[i], 2) Math.pow Math p + 1 - x[i] p + 1 p 1 x[i] x i 2 System.out.println(Math.min(sum1, sum2)) System.out.println System.out System System.out Math.min(sum1, sum2) Math.min Math sum1 sum2 sc.close() sc.close sc 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 sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    }
} 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 sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    }
} 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 sum = 0;
        for (int i = 0; i < x.length; i++) {
            x[i] = sc.nextInt();
            sum += x[i];
        }
        int p = sum / n;
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < x.length; i++) {
            sum1 += Math.pow(p - x[i], 2); 
            sum2 += Math.pow(p + 1 - x[i], 2); 
        }
        System.out.println(Math.min(sum1, sum2));
        sc.close();
    }
}