import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    } main {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n n = sc.nextInt() n sc.nextInt() sc.nextInt sc ArrayList<Integer> persons = new ArrayList<>(); persons new ArrayList<>() for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            persons.add(sc.nextInt());
        } {
            persons.add(sc.nextInt());
        } persons.add(sc.nextInt()) persons.add persons sc.nextInt() sc.nextInt sc int target = 0; target 0 int min = 100; min 100 int max = 0; max 0 for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        } int i = 0; int i = 0; i 0 i < persons.size() i persons.size() persons.size persons i++ i++ i {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        } {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        } if (persons.get(i) <= min) {
                min = persons.get(i);
            } persons.get(i) <= min persons.get(i) persons.get persons i min {
                min = persons.get(i);
            } min = persons.get(i) min persons.get(i) persons.get persons i for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        } int i = 0; int i = 0; i 0 i < persons.size() i persons.size() persons.size persons i++ i++ i {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        } {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        } if (persons.get(i) >= max) {
                max = persons.get(i);
            } persons.get(i) >= max persons.get(i) persons.get persons i max {
                max = persons.get(i);
            } max = persons.get(i) max persons.get(i) persons.get persons i int targetMin = 0; targetMin 0 for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        } int tenP = min; int tenP = min; tenP min tenP < max tenP max tenP++ tenP++ tenP {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        } {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        } target =0 target 0 for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            } int i = 0; int i = 0; i 0 i < persons.size() i persons.size() persons.size persons i++ i++ i {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            } {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            } target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP) target target + (persons.get(i) - tenP) * (persons.get(i) - tenP) target (persons.get(i) - tenP) * (persons.get(i) - tenP) (persons.get(i) - tenP) persons.get(i) persons.get persons i tenP (persons.get(i) - tenP) persons.get(i) persons.get persons i tenP if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            } tenP == min tenP min {
              targetMin = target;
            } targetMin = target targetMin target if(targetMin > target) {
            	targetMin = target;
            } targetMin > target targetMin target {
            	targetMin = target;
            } targetMin = target targetMin target System.out.println(targetMin) System.out.println System.out System System.out targetMin String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        // 人々の座標
        int n;
        n = sc.nextInt();
        ArrayList<Integer> persons = new ArrayList<>();
 
        for (int i = 0; i < n; i++) {
            persons.add(sc.nextInt());
        }
 
        int target = 0;
        // 点Pの算出
        int min = 100;
        int max = 0;
 
        // min
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) <= min) {
                min = persons.get(i);
            }
        }
 
        // max
        for (int i = 0; i < persons.size(); i++) {
            if (persons.get(i) >= max) {
                max = persons.get(i);
            }
        }
 
        int targetMin = 0;
        // 点Pと各座標の算出
        for (int tenP = min; tenP < max; tenP++) {
        	target =0;
            for (int i = 0; i < persons.size(); i++) {
                target = target + (persons.get(i) - tenP) * (persons.get(i) - tenP);
            }
            if(tenP == min) {
              targetMin = target;
            }else if(targetMin > target) {
            	targetMin = target;
            }
        }
 
        System.out.println(targetMin);
    }
}