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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
}
 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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
} 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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    } C public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        } solve {
            // 入力
            int n = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        } int n = Integer.parseInt(in.next()); n Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in double l = 0; l 0 int x[] = new int[n]; x new int[n] n for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            } {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            } x[i] = Integer.parseInt(in.next()) x[i] x i Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in l += x[i] l x[i] x i if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            } l % n != 0 l % n l n 0 {
                l = Math.round(l / n);
            } l = Math.round(l / n) l Math.round(l / n) Math.round Math l / n l n {
                l /= n;
            } l /= n l n long ans = 0; ans 0 for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            } {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            } ans += Math.abs(l - x[i]) * Math.abs(l - x[i]) ans Math.abs(l - x[i]) * Math.abs(l - x[i]) Math.abs(l - x[i]) Math.abs Math l - x[i] l x[i] x i Math.abs(l - x[i]) Math.abs Math l - x[i] l x[i] x i out.println(ans) out.println out ans 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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
} 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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
} 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 = Integer.parseInt(in.next());
            double l = 0;
            int x[] = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = Integer.parseInt(in.next());
                l += x[i];
            }
            if (l % n != 0) {
                l = Math.round(l / n);
            } else {
                l /= n;
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                //ans += (long) Math.pow(Math.abs(l-x[i]),2);
                ans += Math.abs(l - x[i]) * Math.abs(l - x[i]);
            }

            // 出力
            out.println(ans);

        }

    }
}

