import 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+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  }
} 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[] X = new int[N+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  } 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+1]; X new int[N+1] N+1 N 1 X[0] = 0 X[0] X 0 0 for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
      X[i] = sc.nextInt();
    } {
      X[i] = sc.nextInt();
    } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc int hp = 2147483647; hp 2147483647 for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    } int P = 0; int P = 0; P 0 P <= N*3 P N*3 N 3 P++ P++ P {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    } {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    } int sum = 0; sum 0 for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      } int j = 1; int j = 1; j 1 j <= N j N j++ j++ j {
        sum += (X[j]-P) * (X[j]-P);
      } {
        sum += (X[j]-P) * (X[j]-P);
      } sum += (X[j]-P) * (X[j]-P) sum (X[j]-P) * (X[j]-P) (X[j]-P) X[j] X j P (X[j]-P) X[j] X j P if (sum < hp) {
        hp = sum;
      } sum < hp sum hp {
        hp = sum;
      } hp = sum hp sum System.out.println(hp) System.out.println System.out System System.out hp 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+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] X = new int[N+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  }
} Main
import 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+1];
    X[0] = 0;
    for (int i = 1; i <= N; i++) {
      X[i] = sc.nextInt();
    }
    
    int hp = 2147483647;
    for (int P = 0; P <= N*3; P++) {
      int sum = 0;
      for (int j = 1; j <= N; j++) {
        sum += (X[j]-P) * (X[j]-P);
      }
      if (sum < hp) {
        hp = sum;
      }
    }
    
    System.out.println(hp);
  }
}