import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] point = new int[count];
        for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        }
      
        Arrays.sort(point);
        int min = point[0];
        int max = point[count - 1];
        int answer = Integer.MAX_VALUE;
        for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        }
        System.out.println(answer);
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] point = new int[count];
        for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        }
      
        Arrays.sort(point);
        int min = point[0];
        int max = point[count - 1];
        int answer = Integer.MAX_VALUE;
        for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        }
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] point = new int[count];
        for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        }
      
        Arrays.sort(point);
        int min = point[0];
        int max = point[count - 1];
        int answer = Integer.MAX_VALUE;
        for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        }
        System.out.println(answer);
    } main {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] point = new int[count];
        for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        }
      
        Arrays.sort(point);
        int min = point[0];
        int max = point[count - 1];
        int answer = Integer.MAX_VALUE;
        for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        }
        System.out.println(answer);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc int[] point = new int[count]; point new int[count] count for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        } int index = 0; int index = 0; index 0 index < count index count index++ index++ index {
          point[index] = sc.nextInt();
        } {
          point[index] = sc.nextInt();
        } point[index] = sc.nextInt() point[index] point index sc.nextInt() sc.nextInt sc Arrays.sort(point) Arrays.sort Arrays point int min = point[0]; min point[0] point 0 int max = point[count - 1]; max point[count - 1] point count - 1 count 1 int answer = Integer.MAX_VALUE; answer Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        } int n = min; int n = min; n min n <= max n max n++ n++ n {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        } {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        } int total = 0; total 0 for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          } int p point {
            total += (int)StrictMath.pow(n - p, 2);
          } {
            total += (int)StrictMath.pow(n - p, 2);
          } total += (int)StrictMath.pow(n - p, 2) total (int)StrictMath.pow(n - p, 2) StrictMath.pow StrictMath n - p n p 2 if(answer > total) {
            answer = total;
          } answer > total answer total {
            answer = total;
          } answer = total answer total System.out.println(answer) System.out.println System.out System System.out answer String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
        int[] point = new int[count];
        for(int index = 0; index < count; index++) {
          point[index] = sc.nextInt();
        }
      
        Arrays.sort(point);
        int min = point[0];
        int max = point[count - 1];
        int answer = Integer.MAX_VALUE;
        for(int n = min; n <= max; n++) {
          int total = 0;
          for(int p : point) {
            total += (int)StrictMath.pow(n - p, 2);
          }
          if(answer > total) {
            answer = total;
          }
        }
        System.out.println(answer);
    }
}