import java.util.*;
 
public class Main{
  public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  }
} Main public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  } main {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int[] x = new int[n]; x new int[n] n int max = 0 max 0 min = 0; min 0 for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    } {
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    } x[i] = s.nextInt() x[i] x i s.nextInt() s.nextInt s if(i == 0 || x[i] < min){ min = x[i]; } i == 0 || x[i] < min i == 0 i 0 x[i] < min x[i] x i min { min = x[i]; } min = x[i] min x[i] x i if(i == 0 || x[i] > max){ max = x[i]; } i == 0 || x[i] > max i == 0 i 0 x[i] > max x[i] x i max { max = x[i]; } max = x[i] max x[i] x i int minv = 0; minv 0 for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    } int i = min; int i = min; i min i < max i max i++ i++ i {
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    } {
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    } int tmp = 0; tmp 0 for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
        tmp+=(x[j]-i)*(x[j]-i);
      } {
        tmp+=(x[j]-i)*(x[j]-i);
      } tmp+=(x[j]-i)*(x[j]-i) tmp (x[j]-i)*(x[j]-i) (x[j]-i) x[j] x j i (x[j]-i) x[j] x j i if(i == min || tmp < minv){minv = tmp;} i == min || tmp < minv i == min i min tmp < minv tmp minv {minv = tmp;} minv = tmp minv tmp System.out.println(minv) System.out.println System.out System System.out minv String...args args public class Main{
  public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  }
} public class Main{
  public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  }
} Main
import java.util.*;
 
public class Main{
  public static void main(String...args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt(); int[] x = new int[n];
    int max = 0, min = 0;
    for(int i = 0;i < n;i++){
      x[i] = s.nextInt();
      if(i == 0 || x[i] < min){ min = x[i]; }
      if(i == 0 || x[i] > max){ max = x[i]; }
    }
    int minv = 0;
    for(int i = min;i < max;i++){
      int tmp = 0;
      for(int j = 0;j < n;j++){
        tmp+=(x[j]-i)*(x[j]-i);
      }
      if(i == min || tmp < minv){minv = tmp;}
    }
    System.out.println(minv);
  }
}