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];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
} 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];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X[] = new int[N+1];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X[] = new int[N+1];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  } 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 int total = 0; total 0 for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    } int i = 1 ; int i = 1 ; i 1 i <= N i N i++ i++ i {
      X[i] = sc.nextInt();
      total += X[i];
    } {
      X[i] = sc.nextInt();
      total += X[i];
    } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc total += X[i] total X[i] X i int ave = total / N; ave total / N total N int ave1 = ave + 1; ave1 ave + 1 ave 1 int p = 0; p 0 int p1 = 0; p1 0 for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    } int i = 1 ; int i = 1 ; i 1 i <= N i N i++ i++ i {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    } {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    } p += (X[i] - ave) * (X[i] - ave) p (X[i] - ave) * (X[i] - ave) (X[i] - ave) X[i] X i ave (X[i] - ave) X[i] X i ave p1 += (X[i] - ave1) * (X[i] - ave1) p1 (X[i] - ave1) * (X[i] - ave1) (X[i] - ave1) X[i] X i ave1 (X[i] - ave1) X[i] X i ave1 System.out.println(Math.min(p, p1)) System.out.println System.out System System.out Math.min(p, p1) Math.min Math p p1 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];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
} 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];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
} 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];
    
    int total = 0;
    for (int i = 1 ; i <= N ; i++) {
      X[i] = sc.nextInt();
      total += X[i];
    }
    
    int ave = total / N;
    int ave1 = ave + 1;

    int p = 0;
    int p1 = 0;
    for (int i = 1 ; i <= N ; i++) {
      p += (X[i] - ave) * (X[i] - ave);
      p1 += (X[i] - ave1) * (X[i] - ave1);
    }
    System.out.println(Math.min(p, p1));
  }
}