import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer X[] = new Integer[N];
    int sum = 0;
    int summ = 0;
    for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    }
    //真ん中を求める
    int HP = (sum / N);
    int HPP = (sum / N) + 1;
    sum = 0;
    //体力消耗量
    for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    }
    for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    }
    if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    }
  }
} import java.util.Scanner; Scanner java.util import java.util.List; List java.util import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.Arrays; Arrays java.util import java.util.Collections; Collections java.util import java.util.*; util.* java class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer X[] = new Integer[N];
    int sum = 0;
    int summ = 0;
    for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    }
    //真ん中を求める
    int HP = (sum / N);
    int HPP = (sum / N) + 1;
    sum = 0;
    //体力消耗量
    for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    }
    for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    }
    if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    }
  }
} Main public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer X[] = new Integer[N];
    int sum = 0;
    int summ = 0;
    for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    }
    //真ん中を求める
    int HP = (sum / N);
    int HPP = (sum / N) + 1;
    sum = 0;
    //体力消耗量
    for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    }
    for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    }
    if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    }
  } main {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer X[] = new Integer[N];
    int sum = 0;
    int summ = 0;
    for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    }
    //真ん中を求める
    int HP = (sum / N);
    int HPP = (sum / N) + 1;
    sum = 0;
    //体力消耗量
    for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    }
    for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    }
    if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    }
  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan Integer X[] = new Integer[N]; X new Integer[N] N int sum = 0; sum 0 int summ = 0; summ 0 for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      X[i] = scan.nextInt();
      sum += X[i];
    } {
      X[i] = scan.nextInt();
      sum += X[i];
    } X[i] = scan.nextInt() X[i] X i scan.nextInt() scan.nextInt scan sum += X[i] sum X[i] X i int HP = (sum / N); HP (sum / N) sum N int HPP = (sum / N) + 1; HPP (sum / N) + 1 (sum / N) sum N 1 sum = 0 sum 0 for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      sum += (X[i] - HP) * (X[i] - HP);
    } {
      sum += (X[i] - HP) * (X[i] - HP);
    } sum += (X[i] - HP) * (X[i] - HP) sum (X[i] - HP) * (X[i] - HP) (X[i] - HP) X[i] X i HP (X[i] - HP) X[i] X i HP for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      summ += (X[i] - HPP) * (X[i] - HPP);
    } {
      summ += (X[i] - HPP) * (X[i] - HPP);
    } summ += (X[i] - HPP) * (X[i] - HPP) summ (X[i] - HPP) * (X[i] - HPP) (X[i] - HPP) X[i] X i HPP (X[i] - HPP) X[i] X i HPP if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    } sum < summ sum summ {
      System.out.println(sum);
    } System.out.println(sum) System.out.println System.out System System.out sum {
      System.out.println(summ);
    } System.out.println(summ) System.out.println System.out System System.out summ String[] args args
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    Integer X[] = new Integer[N];
    int sum = 0;
    int summ = 0;
    for (int i = 0; i < N; i++) {
      X[i] = scan.nextInt();
      sum += X[i];
    }
    //真ん中を求める
    int HP = (sum / N);
    int HPP = (sum / N) + 1;
    sum = 0;
    //体力消耗量
    for (int i = 0; i < N ; i++) {
      sum += (X[i] - HP) * (X[i] - HP);
    }
    for (int i = 0; i < N ; i++) {
      summ += (X[i] - HPP) * (X[i] - HPP);
    }
    if (sum < summ) {
      System.out.println(sum);
    }
    else{
      System.out.println(summ);
    }
  }
}
