import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  }
}
 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 min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int min = 0; min 0 int max = 0; max 0 int[] X = new int[N]; X new int[N] N for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    } {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    } X[i] =sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc if(min > X[i] || min ==0){
        min = X[i];
      } min > X[i] || min ==0 min > X[i] min X[i] X i min ==0 min 0 {
        min = X[i];
      } min = X[i] min X[i] X i if(  X[i] > max){
        max = X[i];
      } X[i] > max X[i] X i max {
        max = X[i];
      } max = X[i] max X[i] X i int sum = 0; sum 0 int  sum_min = 0; sum_min 0 int tmp = 0; tmp 0 for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    } int j = min; int j = min; j min j < max j max j++ j++ j {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    } {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    } for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       } int k = 0; int k = 0; k 0 k < N k N k++ k++ k {
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       } {
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       } tmp = Math.abs(j -X[k]) tmp Math.abs(j -X[k]) Math.abs Math j -X[k] j X[k] X k sum = tmp * tmp + sum sum tmp * tmp + sum tmp * tmp tmp tmp sum if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       } sum_min == 0 || sum <=sum_min sum_min == 0 sum_min 0 sum <=sum_min sum sum_min {
        sum_min = sum;
       } sum_min = sum sum_min sum sum = 0 sum 0 System.out.println(sum_min) System.out.println System.out System System.out sum_min String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int min = 0;
    int max = 0;
    int[] X = new int[N];

    for (int i = 0; i < N; i++) {
      X[i] =sc.nextInt();
      if(min > X[i] || min ==0){
        min = X[i];
      }
      if(  X[i] > max){
        max = X[i];
      }
    }

    int sum = 0;
    int  sum_min = 0;
    int tmp = 0;
    for (int j = min; j < max; j++) {
       for(int k = 0; k < N; k++){
         tmp = Math.abs(j -X[k]);
         sum = tmp * tmp + sum;
       }
       if(sum_min == 0 || sum <=sum_min){
        sum_min = sum;
       }
       sum = 0;
    }    
    System.out.println(sum_min);
  }
}

