import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] x = new int[n]; x new int[n] n for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            x[i] = Integer.parseInt(sc.next());
        } {
            x[i] = Integer.parseInt(sc.next());
        } x[i] = Integer.parseInt(sc.next()) x[i] x i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int cost = 0 cost 0 min=2000000; min 2000000 for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        } int p = 0; int p = 0; p 0 p < 120 p 120 p++ p++ p {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        } {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        } cost=0 cost 0 for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                cost+=(x[i]-p)*(x[i]-p);
            } {
                cost+=(x[i]-p)*(x[i]-p);
            } cost+=(x[i]-p)*(x[i]-p) cost (x[i]-p)*(x[i]-p) (x[i]-p) x[i] x i p (x[i]-p) x[i] x i p if(cost < min){
                min=cost;
            } cost < min cost min {
                min=cost;
            } min=cost min cost 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) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        
        for(int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
        }
        
        int cost = 0, min=2000000;
        for(int p = 0; p < 120; p++) {
            cost=0;
            for(int i = 0; i < n; i++) {
                cost+=(x[i]-p)*(x[i]-p);
            }
            if(cost < min){
                min=cost;
            }
        }
        System.out.println(min);
    }
}