    import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    }
// end  import java.util.*; util.* java public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    } Main public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    } main {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int n=Integer.parseInt(scan.next()); n Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int max=0; max 0 int min=999; min 999 int x_i; x_i int x[]=new int[n]; x new int[n] n for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		} int i=0; int i=0; i 0 i<n i n ++i ++i i {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		} {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		} x_i=Integer.parseInt(scan.next()) x_i Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan max=Math.max(max, x_i) max Math.max(max, x_i) Math.max Math max x_i min=Math.min(min, x_i) min Math.min(min, x_i) Math.min Math min x_i x[i]=x_i x[i] x i x_i int ans=Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE int sum; sum for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		} int p=min; int p=min; p min p<=max p max ++p ++p p {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		} {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		} sum=0 sum 0 for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			} int i x {
    				sum+=Math.pow(i-p,2);
    			} {
    				sum+=Math.pow(i-p,2);
    			} sum+=Math.pow(i-p,2) sum Math.pow(i-p,2) Math.pow Math i-p i p 2 ans=Math.min(ans, sum) ans Math.min(ans, sum) Math.min Math ans sum System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    } public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    } Main
    import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int max=0;
    		int min=999;
    		int x_i;
    		int x[]=new int[n];
    		for (int i=0;i<n;++i) {
    			x_i=Integer.parseInt(scan.next());
    			max=Math.max(max, x_i);
    			min=Math.min(min, x_i);
    			x[i]=x_i;
    		}
    		int ans=Integer.MAX_VALUE;
    		int sum;
    		for (int p=min;p<=max;++p) {
    			sum=0;
    			for (int i:x) {
    				sum+=Math.pow(i-p,2);
    			}
    			ans=Math.min(ans, sum);
    			
    		}
    		System.out.print(ans);
    		
    }	
    }
// end 