import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    } main {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int[] nums = new int[n]; nums new int[n] n int min = 100; min 100 int max = 1; max 1 for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        } int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        } {
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        } nums[i] = scan.nextInt() nums[i] nums i scan.nextInt() scan.nextInt scan min = Math.min(min, nums[i]) min Math.min(min, nums[i]) Math.min Math min nums[i] nums i max = Math.max(max, nums[i]) max Math.max(max, nums[i]) Math.max Math max nums[i] nums i int result = Integer.MAX_VALUE; result Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        } int i = min; int i = min; i min i <= max i max i ++ i ++ i {
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        } {
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        } int ans = 0; ans 0 for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            } int j = 0; int j = 0; j 0 j < n j n j ++ j ++ j {
                ans += Math.pow(nums[j] - i, 2);
            } {
                ans += Math.pow(nums[j] - i, 2);
            } ans += Math.pow(nums[j] - i, 2) ans Math.pow(nums[j] - i, 2) Math.pow Math nums[j] - i nums[j] nums j i 2 result = Math.min(ans, result) result Math.min(ans, result) Math.min Math ans result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int min = 100;
        int max = 1;
        for (int i = 0; i < n; i ++){
            nums[i] = scan.nextInt();
            min = Math.min(min, nums[i]);
            max = Math.max(max, nums[i]);
        }
        int result = Integer.MAX_VALUE;
        for (int i = min; i <= max; i ++){
            int ans = 0;
            for (int j = 0; j < n; j ++){
                ans += Math.pow(nums[j] - i, 2);
            }
            result = Math.min(ans, result);
        }
        System.out.println(result);
    }
}
