import java.util.*;
class Main{
  static Scanner s = new Scanner(System.in);
  
  public static void main(String[] args){
    
    int N = s.nextInt();
    int[] X = new int[N];
    for(int i=0;i<N;i++) X[i] = s.nextInt();       
    Arrays.sort(X);
    int temp1 = 0;
    int temp2 = 0;

    for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    }
    System.out.println(temp2);
  }
} import java.util.*; util.* java class Main{
  static Scanner s = new Scanner(System.in);
  
  public static void main(String[] args){
    
    int N = s.nextInt();
    int[] X = new int[N];
    for(int i=0;i<N;i++) X[i] = s.nextInt();       
    Arrays.sort(X);
    int temp1 = 0;
    int temp2 = 0;

    for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    }
    System.out.println(temp2);
  }
} Main static Scanner s = new Scanner(System.in); s new Scanner(System.in) public static void main(String[] args){
    
    int N = s.nextInt();
    int[] X = new int[N];
    for(int i=0;i<N;i++) X[i] = s.nextInt();       
    Arrays.sort(X);
    int temp1 = 0;
    int temp2 = 0;

    for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    }
    System.out.println(temp2);
  } main {
    
    int N = s.nextInt();
    int[] X = new int[N];
    for(int i=0;i<N;i++) X[i] = s.nextInt();       
    Arrays.sort(X);
    int temp1 = 0;
    int temp2 = 0;

    for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    }
    System.out.println(temp2);
  } int N = s.nextInt(); N s.nextInt() s.nextInt s int[] X = new int[N]; X new int[N] N for(int i=0;i<N;i++) X[i] = s.nextInt(); int i=0; int i=0; i 0 i<N i N i++ i++ i X[i] = s.nextInt(); X[i] = s.nextInt() X[i] X i s.nextInt() s.nextInt s Arrays.sort(X) Arrays.sort Arrays X int temp1 = 0; temp1 0 int temp2 = 0; temp2 0 for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    } int i=X[0]; int i=X[0]; i X[0] X 0 i<=X[N-1] i X[N-1] X N-1 N 1 i++ i++ i {
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    } {
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    } temp1 = 0 temp1 0 for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      } int j=0; int j=0; j 0 j<N j N j++ j++ j {
        temp1 += Math.pow(X[j]-i,2);
      } {
        temp1 += Math.pow(X[j]-i,2);
      } temp1 += Math.pow(X[j]-i,2) temp1 Math.pow(X[j]-i,2) Math.pow Math X[j]-i X[j] X j i 2 if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2); i==X[0] i X[0] X 0 temp2 =temp1 temp2 temp1 temp2=Math.min(temp1,temp2) temp2 Math.min(temp1,temp2) Math.min Math temp1 temp2 System.out.println(temp2) System.out.println System.out System System.out temp2 String[] args args
import java.util.*;
class Main{
  static Scanner s = new Scanner(System.in);
  
  public static void main(String[] args){
    
    int N = s.nextInt();
    int[] X = new int[N];
    for(int i=0;i<N;i++) X[i] = s.nextInt();       
    Arrays.sort(X);
    int temp1 = 0;
    int temp2 = 0;

    for(int i=X[0];i<=X[N-1];i++){
      temp1 = 0;
      for(int j=0;j<N;j++){
        temp1 += Math.pow(X[j]-i,2);
      }
      if(i==X[0]) temp2 =temp1;
      else temp2=Math.min(temp1,temp2);
    }
    System.out.println(temp2);
  }
}