import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
} import java.util.Scanner; Scanner java.util import java.lang.Math; Math java.lang public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
} Main public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  } main {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int[] X = new int[N]; X new int[N] N int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int max = 0; max 0 for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    } int i=0; int i=0; i 0 i<X.length i X.length X X.length i++ i++ i {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    } {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    } X[i] = scan.nextInt() X[i] X i scan.nextInt() scan.nextInt scan if(min > X[i]) {
        min = X[i];
      } min > X[i] min X[i] X i {
        min = X[i];
      } min = X[i] min X[i] X i if(max < X[i]) {
        max = X[i];
      } max < X[i] max X[i] X i {
        max = X[i];
      } max = X[i] max X[i] X i scan.close() scan.close scan int minsum = Integer.MAX_VALUE; minsum Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    } int i=min; int i=min; i min i<=max i max i++ i++ i {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    } {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    } int sum = 0; sum 0 for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      } int j=0; int j=0; j 0 j<X.length j X.length X X.length j++ j++ j {
        sum += (X[j] - i) * (X[j] -i);
      } {
        sum += (X[j] - i) * (X[j] -i);
      } sum += (X[j] - i) * (X[j] -i) sum (X[j] - i) * (X[j] -i) (X[j] - i) X[j] X j i (X[j] -i) X[j] X j i if(minsum > sum) {
        minsum = sum;
      } minsum > sum minsum sum {
        minsum = sum;
      } minsum = sum minsum sum System.out.println(minsum) System.out.println System.out System System.out minsum String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
} Main
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = 0;
    for(int i=0; i<X.length; i++) {
      X[i] = scan.nextInt();
      if(min > X[i]) {
        min = X[i];
      }
      if(max < X[i]) {
        max = X[i];
      }
    }
    scan.close();

    int minsum = Integer.MAX_VALUE;
    for(int i=min; i<=max; i++) {
      int sum = 0;
      for(int j=0; j<X.length; j++) {
        sum += (X[j] - i) * (X[j] -i);
      }
      if(minsum > sum) {
        minsum = sum;
      }
    }

    System.out.println(minsum);
  }
}