import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  }
} 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 A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int A = 0; A 0 int[] xx = new int[n]; xx new int[n] n for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    } {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    } int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc xx[i] = x xx[i] xx i x A += x A x int p = A/n; p A/n A n int p1 = p+1; p1 p+1 p 1 int B = 0; B 0 int B1 = 0; B1 0 for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    } {
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    } B += Math.pow((xx[i]-p), 2) B Math.pow((xx[i]-p), 2) Math.pow Math (xx[i]-p) xx[i] xx i p 2 B1 += Math.pow((xx[i]-p1), 2) B1 Math.pow((xx[i]-p1), 2) Math.pow Math (xx[i]-p1) xx[i] xx i p1 2 System.out.println(Math.min(B, B1)) System.out.println System.out System System.out Math.min(B, B1) Math.min Math B B1 String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A = 0;
    int[] xx = new int[n];
    for (int i = 0; i < n; i++) {
      int x = sc.nextInt();
      xx[i] = x;
      A += x;
    }
    int p = A/n;
    int p1 = p+1;
    int B = 0;
    int B1 = 0;
    for (int i = 0; i < n; i++){
      B += Math.pow((xx[i]-p), 2);
      B1 += Math.pow((xx[i]-p1), 2);
    }
    System.out.println(Math.min(B, B1));
  }
}