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];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
} 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];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  } 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 int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    } {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc min = Math.min(min, X[i]) min Math.min(min, X[i]) Math.min Math min X[i] X i max = Math.max(max, X[i]) max Math.max(max, X[i]) Math.max Math max X[i] X i int ans = Integer.MAX_VALUE; ans Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    } int p = min; int p = min; p min p <= max p max p++ p++ p {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    } {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    } int sum = 0; sum 0 for (int x : X) {
        sum += (x - p) * (x - p);
      } int x X {
        sum += (x - p) * (x - p);
      } {
        sum += (x - p) * (x - p);
      } sum += (x - p) * (x - p) sum (x - p) * (x - p) (x - p) x p (x - p) x p ans = Math.min(ans, sum) ans Math.min(ans, sum) Math.min Math ans sum System.out.println(ans) System.out.println System.out System System.out ans 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];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
} Main
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];
    int min = Integer.MAX_VALUE;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < N; i++) {
      X[i] = sc.nextInt();
      min = Math.min(min, X[i]);
      max = Math.max(max, X[i]);
    }
    int ans = Integer.MAX_VALUE;
    for (int p = min; p <= max; p++) {
      int sum = 0;
      for (int x : X) {
        sum += (x - p) * (x - p);
      }
      ans = Math.min(ans, sum);
    }
    System.out.println(ans);
  }
}
