import java.util.Arrays;
import java.util.Scanner;

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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_min);
  }
} import java.util.Arrays; Arrays 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 = sc.nextInt();
    int[] x = new int[n];
    for(int i=0; i<n; ++i) x[i] = sc.nextInt();

    Arrays.sort(x);
    int x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_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] x i sc.nextInt() sc.nextInt sc Arrays.sort(x) Arrays.sort Arrays x int x_min = x[0]; x_min x[0] x 0 int x_max = x[n-1]; x_max x[n-1] x n-1 n 1 int move_min = Integer.MAX_VALUE; move_min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    } int j=x_min; int j=x_min; j x_min j<=x_max j x_max ++j ++j j {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    } {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    } int move_sum = 0; move_sum 0 for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      } int i=0; int i=0; i 0 i<n i n ++i ++i i {
        move_sum += (x[i] - j) * (x[i] - j);
      } {
        move_sum += (x[i] - j) * (x[i] - j);
      } move_sum += (x[i] - j) * (x[i] - j) move_sum (x[i] - j) * (x[i] - j) (x[i] - j) x[i] x i j (x[i] - j) x[i] x i j if(move_sum <= move_min) {
        move_min = move_sum;
      } move_sum <= move_min move_sum move_min {
        move_min = move_sum;
      } move_min = move_sum move_min move_sum System.out.println(move_min) System.out.println System.out System System.out move_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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_min);
  }
} Main
import java.util.Arrays;
import java.util.Scanner;

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 x_min = x[0];
    int x_max = x[n-1];

    //nが最大でも100なので全探索でやる
    int move_min = Integer.MAX_VALUE;
    for(int j=x_min; j<=x_max; ++j) {
      int move_sum = 0;
      for(int i=0; i<n; ++i) {
        move_sum += (x[i] - j) * (x[i] - j);
      }
      if(move_sum <= move_min) {
        move_min = move_sum;
      }
    }
    System.out.println(move_min);
  }
}