import java.lang.Math;
import java.util.Scanner;
 
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<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        int p = sum / n;
        int s1=0,s2=0;
        for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        }
        System.out.print(Math.min(s1,s2));
    }
} import java.lang.Math; Math java.lang import java.util.Scanner; Scanner java.util 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<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        int p = sum / n;
        int s1=0,s2=0;
        for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        }
        System.out.print(Math.min(s1,s2));
    }
} 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<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        int p = sum / n;
        int s1=0,s2=0;
        for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        }
        System.out.print(Math.min(s1,s2));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] X  = new int[n];
        int sum = 0;
        for(int i=0 ; i<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        int p = sum / n;
        int s1=0,s2=0;
        for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        }
        System.out.print(Math.min(s1,s2));
    } 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<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } int i=0 ; int i=0 ; i 0 i<n i n i++ i++ i {
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } {
            X[i] = sc.nextInt();
            sum = sum + X[i];
        } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc sum = sum + X[i] sum sum + X[i] sum X[i] X i int p = sum / n; p sum / n sum n int s1=0 s1 0 s2=0; s2 0 for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        } int i= 0; int i= 0; i 0 i<n i n i++ i++ i {
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        } {
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        } s1 = s1 + (X[i]-p)*(X[i]-p) s1 s1 + (X[i]-p)*(X[i]-p) s1 (X[i]-p)*(X[i]-p) (X[i]-p) X[i] X i p (X[i]-p) X[i] X i p s2 = s2 + (X[i]-p-1)*(X[i]-p-1) s2 s2 + (X[i]-p-1)*(X[i]-p-1) s2 (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.print(Math.min(s1,s2)) System.out.print System.out System System.out Math.min(s1,s2) Math.min Math s1 s2 String[] args args
import java.lang.Math;
import java.util.Scanner;
 
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<n;i++){
            X[i] = sc.nextInt();
            sum = sum + X[i];
        }
        int p = sum / n;
        int s1=0,s2=0;
        for(int i= 0;i<n;i++){
            s1 = s1 + (X[i]-p)*(X[i]-p);
            s2 = s2 + (X[i]-p-1)*(X[i]-p-1);
        }
        System.out.print(Math.min(s1,s2));
    }
}