import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    }
    
    int min = x[0];
    int max = x[0];
    
    for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    }
    
    int total = 0;
    int st = 2147483647;
    
    for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    }
    
    System.out.println(st);
  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    }
    
    int min = x[0];
    int max = x[0];
    
    for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    }
    
    int total = 0;
    int st = 2147483647;
    
    for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    }
    
    System.out.println(st);
  }
} Main public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    }
    
    int min = x[0];
    int max = x[0];
    
    for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    }
    
    int total = 0;
    int st = 2147483647;
    
    for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    }
    
    System.out.println(st);
  } main {
    Scanner sc= new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    }
    
    int min = x[0];
    int max = x[0];
    
    for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    }
    
    int total = 0;
    int st = 2147483647;
    
    for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    }
    
    System.out.println(st);
  } 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]; x new int[n] n for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    } int i=0; int i=0; i 0 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 min = x[0]; min x[0] x 0 int max = x[0]; max x[0] x 0 for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    } {
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    } if(min > x[i]){
        min = x[i];
      } min > x[i] min x[i] x i {
        min = x[i];
      } min = x[i] min x[i] x i if(max < x[i]){
        max = x[i];
      } max < x[i] max x[i] x i {
        max = x[i];
      } max = x[i] max x[i] x i int total = 0; total 0 int st = 2147483647; st 2147483647 for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    } int i=min; int i=min; i min i<=max i max i++ i++ i {
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    } {
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    } for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      } int j=0; int j=0; j 0 j<n j n j++ j++ j {
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      } {
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      } total += (x[j]-i) * (x[j]-i) total (x[j]-i) * (x[j]-i) (x[j]-i) x[j] x j i (x[j]-i) x[j] x j i if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        } j == n-1 && st > total j == n-1 j n-1 n 1 st > total st total {
          st = total;
          total = 0;
        } st = total st total total = 0 total 0 if(j == n-1){
          total = 0;
        }else{
        
        } j == n-1 j n-1 n 1 {
          total = 0;
        } total = 0 total 0 {
        
        } System.out.println(st) System.out.println System.out System System.out st String[] args args
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc= new Scanner(System.in);
    int n = sc.nextInt();
    int[] x = new int[n];
    
    for(int i=0; i<n; i++){
      x[i] = sc.nextInt();
    }
    
    int min = x[0];
    int max = x[0];
    
    for(int i=0; i<n; i++){
      if(min > x[i]){
        min = x[i];
      }
      
      if(max < x[i]){
        max = x[i];
      }
    }
    
    int total = 0;
    int st = 2147483647;
    
    for(int i=min; i<=max; i++){
      for(int j=0; j<n; j++){
        total += (x[j]-i) * (x[j]-i);
        if(j == n-1 && st > total){
          st = total;
          total = 0;
        }else if(j == n-1){
          total = 0;
        }else{
        
        }
      }
    }
    
    System.out.println(st);
  }
}
