import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) C solver = new C(); solver new C() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    } C public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        } solve {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] x = new int[n]; x new int[n] n int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                x[i] = in.nextInt();
                cnt += x[i];
            } {
                x[i] = in.nextInt();
                cnt += x[i];
            } x[i] = in.nextInt() x[i] x i in.nextInt() in.nextInt in cnt += x[i] cnt x[i] x i int dist = (int) Math.round((double) cnt / n); dist (int) Math.round((double) cnt / n) Math.round Math (double) cnt / n (double) cnt n int power = 0; power 0 for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                power += (x[i] - dist) * (x[i] - dist);
            } {
                power += (x[i] - dist) * (x[i] - dist);
            } power += (x[i] - dist) * (x[i] - dist) power (x[i] - dist) * (x[i] - dist) (x[i] - dist) x[i] x i dist (x[i] - dist) x[i] x i dist out.println(power) out.println out power int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int[] x = new int[n];

            int cnt = 0;

            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
                cnt += x[i];
            }

            int dist = (int) Math.round((double) cnt / n);

            int power = 0;

            for (int i = 0; i < n; i++) {
                power += (x[i] - dist) * (x[i] - dist);
            }
            out.println(power);


        }

    }
}

