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];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    }
} 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];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int[] x = new int[n];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    } main {
        Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int[] x = new int[n];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    } 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 sq = 0; sq 0 int sum = 0; sum 0 for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        } {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc sq += x[i] * x[i] sq x[i] * x[i] x[i] x i x[i] x i sum += x[i] sum x[i] x i int p = sum / n; p sum / n sum n int p1 = p + 1; p1 p + 1 p 1 int r1 = (n * p - 2 * sum) * p; r1 (n * p - 2 * sum) * p (n * p - 2 * sum) n * p n p 2 * sum 2 sum p int r2 = (n * p1 - 2 * sum) * p1; r2 (n * p1 - 2 * sum) * p1 (n * p1 - 2 * sum) n * p1 n p1 2 * sum 2 sum p1 int r = sq + Integer.min(r1, r2); r sq + Integer.min(r1, r2) sq Integer.min(r1, r2) Integer.min Integer r1 r2 System.out.println(r) System.out.println System.out System System.out r 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];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int[] x = new int[n];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    }
} Main
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];
	    int sq = 0;
	    int sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            sq += x[i] * x[i];
            sum += x[i];
        }
	    int p = sum / n;
        int p1 = p + 1;

        int r1 = (n * p - 2 * sum) * p;
        int r2 = (n * p1 - 2 * sum) * p1;
        int r = sq + Integer.min(r1, r2);
        System.out.println(r);
    }
}
