import java.util.*;
public 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();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(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[] x=new int[n];
    for(int i=0;i<n;i++) x[i]=sc.nextInt();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(min);
  }
} 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();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(min);
  } 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();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(min);
  } 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] x i sc.nextInt() sc.nextInt sc Arrays.sort(x) Arrays.sort Arrays x long[] p=new long[201]; p new long[201] 201 long min=999999999999999999L; min 999999999999999999L for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    } int i=-100; int i=-100; i -100 100 i<=100 i 100 i++ i++ i {
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    } {
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    } for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      } int j=0; int j=0; j 0 j<n j n j++ j++ j {
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      } {
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      } p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0) p[i+100] p i+100 i 100 (long)Math.pow((double)x[j]-(double)i,2.0) Math.pow Math (double)x[j]-(double)i (double)x[j] x j (double)i 2.0 min=Math.min(min,p[i+100]) min Math.min(min,p[i+100]) Math.min Math min p[i+100] p i+100 i 100 System.out.println(min) System.out.println System.out System System.out min String[] args args public 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();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(min);
  }
} public 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();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(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[] x=new int[n];
    for(int i=0;i<n;i++) x[i]=sc.nextInt();
    Arrays.sort(x);
    long[] p=new long[201];
    long min=999999999999999999L;
    for(int i=-100;i<=100;i++){
      for(int j=0;j<n;j++){
        p[i+100]+=(long)Math.pow((double)x[j]-(double)i,2.0);
      }
      min=Math.min(min,p[i+100]);
    }
    System.out.println(min);
  }
}