import java.util.Scanner;
  public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  } import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  } Main public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    } main {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int Max = 0; Max 0 int sum1 = 0; sum1 0 int sum2 = 0; sum2 0 int[] X = new int[N]; X new int[N] N for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      } {
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      } X[i] = sc.nextInt() X[i] X i sc.nextInt() sc.nextInt sc 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 sc.close() sc.close sc sum1 = pow(1,N,X) sum1 pow(1,N,X) pow 1 N X for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      } int j=2; int j=2; j 2 j<=Max j Max j++ j++ j {
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      } {
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      } sum2 = pow(j,N,X) sum2 pow(j,N,X) pow j N X if(sum1>sum2){
            sum1=sum2;
          } sum1>sum2 sum1 sum2 {
            sum1=sum2;
          } sum1=sum2 sum1 sum2 System.out.println(sum1) System.out.println System.out System System.out sum1 String args[] args private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    } pow {
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    } int sum = 0; sum 0 for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      } int k=0; int k=0; k 0 k<N k N k++ k++ k {
        sum+=Math.pow(array[k]-n1,2);
      } {
        sum+=Math.pow(array[k]-n1,2);
      } sum+=Math.pow(array[k]-n1,2) sum Math.pow(array[k]-n1,2) Math.pow Math array[k]-n1 array[k] array k n1 2 return sum; sum int n1 n1 int N N int array[] array public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  } public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  } Main
import java.util.Scanner;
  public class Main{
    public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int Max = 0;
      int sum1 = 0;
      int sum2 = 0;
      int[] X = new int[N];

      for(int i=0;i<N;i++){
        X[i] = sc.nextInt();
        if(Max<X[i]){
          Max=X[i];
        }
      }
      sc.close();
      sum1 = pow(1,N,X);
      for(int j=2;j<=Max;j++){
          sum2 = pow(j,N,X);
          if(sum1>sum2){
            sum1=sum2;
          }
      }
      System.out.println(sum1);
    }
    private static int pow(int n1,int N,int array[]){
      int sum = 0;
      for(int k=0;k<N;k++){
        sum+=Math.pow(array[k]-n1,2);
      }
      return sum;
    }
  }