import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int a[] = new int[N]; a new int[N] N for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int sum = 0; sum 0 List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() int distance; distance for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        } int i=0; int i=0; i 0 i<=100 i 100 i++ i++ i {
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        } {
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        } for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            } int j=0; int j=0; j 0 j<N j N j++ j++ j {
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            } {
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            } distance = a[j] - i distance a[j] - i a[j] a j i sum += Math.pow(distance,2) sum Math.pow(distance,2) Math.pow Math distance 2 list.add(sum) list.add list sum sum = 0 sum 0 Collections.sort(list) Collections.sort Collections list System.out.println(list.get(0)) System.out.println System.out System System.out list.get(0) list.get list 0 String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a[] = new int[N];
        
        for(int i=0;i<N;i++){
            a[i] = sc.nextInt();
        }
        
        int sum = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        
        int distance;
        for(int i=0;i<=100;i++){
            for(int j=0;j<N;j++){
                distance = a[j] - i;
                sum += Math.pow(distance,2);
            }
        list.add(sum);
        sum = 0;
        }
        
        Collections.sort(list);
        
        System.out.println(list.get(0));
    }
}
