import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

    }
}
 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.StringTokenizer; StringTokenizer java.util import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.InputStream; InputStream java.io public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        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 FastReader in = new FastReader(inputStream); in new FastReader(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) CRally solver = new CRally(); solver new CRally() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    } CRally public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        } solve {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        } int n = in.nextInt(); n in.nextInt() in.nextInt in int[] a = in.nextArrInt(n); a in.nextArrInt(n) in.nextArrInt in n int best = Integer.MAX_VALUE / 2; best Integer.MAX_VALUE / 2 Integer.MAX_VALUE Integer Integer.MAX_VALUE 2 for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            } int i = 1; int i = 1; i 1 i <= 100 i 100 i++ i++ i {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            } {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            } int cost = 0; cost 0 for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                    cost += (a[j] - i) * (a[j] - i);
                } {
                    cost += (a[j] - i) * (a[j] - i);
                } cost += (a[j] - i) * (a[j] - i) cost (a[j] - i) * (a[j] - i) (a[j] - i) a[j] a j i (a[j] - i) a[j] a j i best = Math.min(best, cost) best Math.min(best, cost) Math.min Math best cost out.println(best) out.println out best int testNumber testNumber FastReader in in PrintWriter out out static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

    } FastReader BufferedReader br; br StringTokenizer st; st public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        } FastReader {
            this(new InputStreamReader(in));
        } this(new InputStreamReader(in)) this new InputStreamReader(in) InputStream in in public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        } FastReader {
            br = new BufferedReader(input);
        } br = new BufferedReader(input) br new BufferedReader(input) InputStreamReader input input public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } String s = br.readLine(); s br.readLine() br.readLine br if (s == null)
                        return null; s == null s null return null; null st = new StringTokenizer(s) st new StringTokenizer(s) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        } nextArrInt {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        } int[] a = new int[n]; a new int[n] n for (int i = 0; i < a.length; i++)
                a[i] = nextInt(); int i = 0; int i = 0; i 0 i < a.length i a.length a a.length i++ i++ i a[i] = nextInt(); a[i] = nextInt() a[i] a i nextInt() nextInt return a; a int n n public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CRally solver = new CRally();
        solver.solve(1, in, out);
        out.close();
    }

    static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

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

    static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CRally {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextArrInt(n);
            int best = Integer.MAX_VALUE / 2;
            for (int i = 1; i <= 100; i++) {
                int cost = 0;
                for (int j = 0; j < n; j++) {
                    cost += (a[j] - i) * (a[j] - i);
                }
                best = Math.min(best, cost);
            }

            out.println(best);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrInt(int n) {
            int[] a = new int[n];
            for (int i = 0; i < a.length; i++)
                a[i] = nextInt();
            return a;
        }

    }
}

