import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
}
} import java.util.*; util.* java public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
}
} Main public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
} main {
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int[] x = new int[N]; x new int[N] N for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	} int i=0; int i=0; i 0 i<N i N i++ i++ i {
		x[i] = sc.nextInt();
	} {
		x[i] = sc.nextInt();
	} x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc Arrays.sort(x) Arrays.sort Arrays x int tairyoku = 0; tairyoku 0 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    } int p=x[0]; int p=x[0]; p x[0] x 0 p<=x[N-1] p x[N-1] x N-1 N 1 p++ p++ p {
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    } {
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    } tairyoku = 0 tairyoku 0 for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      } int j=0; int j=0; j 0 j<N j N j++ j++ j {
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      } {
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      } tairyoku = tairyoku + (x[j]-p)*(x[j]-p) tairyoku tairyoku + (x[j]-p)*(x[j]-p) tairyoku (x[j]-p)*(x[j]-p) (x[j]-p) x[j] x j p (x[j]-p) x[j] x j p if(min > tairyoku){
        min = tairyoku;
      } min > tairyoku min tairyoku {
        min = tairyoku;
      } min = tairyoku min tairyoku System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
}
} public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
}
} Main
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
  	int[] x = new int[N];
	for (int i=0;i<N;i++){
		x[i] = sc.nextInt();
	}
  	Arrays.sort(x);
  	int tairyoku = 0;
  	int min = Integer.MAX_VALUE;
  	for (int p=x[0];p<=x[N-1];p++){
      tairyoku = 0;
      for(int j=0;j<N;j++){
        tairyoku = tairyoku + (x[j]-p)*(x[j]-p);
      }
      if(min > tairyoku){
        min = tairyoku;
      }
      //System.out.println("p:"+p+",tairyoku:"+tairyoku);
    }

	System.out.println(min);
}
}