
import java.util.Arrays;
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];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    }

} import java.util.Arrays; Arrays java.util 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];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    } main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    } 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 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] x i sc.nextInt() sc.nextInt sc Arrays.sort(x) Arrays.sort Arrays x int sum = 0; sum 0 for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        } int p = x[0]; int p = x[0]; p x[0] x 0 p <= x[N - 1] p x[N - 1] x N - 1 N 1 p++ p++ p {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        } {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        } int tmp = 0; tmp 0 for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p); int i = 0; int i = 0; i 0 i < N i N i++ i++ i tmp += (x[i] - p) * (x[i] - p); tmp += (x[i] - p) * (x[i] - p) tmp (x[i] - p) * (x[i] - p) (x[i] - p) x[i] x i p (x[i] - p) x[i] x i p if(p == x[0]) sum = tmp; p == x[0] p x[0] x 0 sum = tmp sum tmp if(tmp <= sum) sum = tmp; tmp <= sum tmp sum sum = tmp sum tmp System.out.println(sum) System.out.println System.out System System.out sum 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];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    }

} public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] x = new int[N];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    }

} Main

import java.util.Arrays;
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];
        for(int i = 0; i < N; i++)
            x[i] = sc.nextInt();

        Arrays.sort(x);

        int sum = 0;
        for(int p = x[0]; p <= x[N - 1]; p++) {
            int tmp = 0;
            for(int i = 0; i < N; i++) 
                tmp += (x[i] - p) * (x[i] - p);
            
            if(p == x[0]) sum = tmp;
            if(tmp <= sum) sum = tmp;
        }

        System.out.println(sum);
    }

}
