import java.util.Scanner;

public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
} Main public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    } converter {
        return Integer.toString(Integer.parseInt(number, base), dest);
    } return Integer.toString(Integer.parseInt(number, base), dest); Integer.toString(Integer.parseInt(number, base), dest) Integer.toString Integer Integer.parseInt(number, base) Integer.parseInt Integer number base dest String number number int base base int dest dest private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    } converter {
        return converter(number, 10, dest).length();
    } return converter(number, 10, dest).length(); converter(number, 10, dest).length() converter(number, 10, dest).length converter(number, 10, dest) converter number 10 dest String number number int dest dest private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    } stamina {
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    } int res = Integer.MAX_VALUE; res Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        } int p = 1; int p = 1; p 1 p <= 1000 p 1000 p++ p++ p {
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        } {
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        } int sum = 0; sum 0 for(int a: A){
                sum += ((a - p) * (a - p));
            } int a A {
                sum += ((a - p) * (a - p));
            } {
                sum += ((a - p) * (a - p));
            } sum += ((a - p) * (a - p)) sum ((a - p) * (a - p)) (a - p) a p (a - p) a p res = Math.min(sum, res) res Math.min(sum, res) Math.min Math sum res return res; res int[] A A int n n public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    } main {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int[] dest = new int[n]; dest new int[n] n for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            dest[i] = scanner.nextInt();
        } {
            dest[i] = scanner.nextInt();
        } dest[i] = scanner.nextInt() dest[i] dest i scanner.nextInt() scanner.nextInt scanner System.out.println(stamina(dest, n)) System.out.println System.out System System.out stamina(dest, n) stamina dest n String[] args args public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
} public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
} Main
import java.util.Scanner;

public class Main {

    public static String converter(String number, int base, int dest){
        return Integer.toString(Integer.parseInt(number, base), dest);
    }

    private static int converter(String number, int dest){
        return converter(number, 10, dest).length();
    }

    private static int stamina(int[] A, int n){
        int res = Integer.MAX_VALUE;
        for(int p = 1; p <= 1000; p++){
            int sum = 0;
            for(int a: A){
                sum += ((a - p) * (a - p));
            }
            res = Math.min(sum, res);
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] dest = new int[n];
        for(int i = 0; i < n; i++){
            dest[i] = scanner.nextInt();
        }
        System.out.println(stamina(dest, n));
    }
}
