import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util 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[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] coordinates = new int[n]; coordinates new int[n] n int max = 1; max 1 int min = 100; min 100 for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    } {
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    } coordinates[i] = sc.nextInt() coordinates[i] coordinates i sc.nextInt() sc.nextInt sc max = Math.max(max, coordinates[i]) max Math.max(max, coordinates[i]) Math.max Math max coordinates[i] coordinates i min = Math.min(min, coordinates[i]) min Math.min(min, coordinates[i]) Math.min Math min coordinates[i] coordinates i int energy = 250000; energy 250000 for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    } int i = min; int i = min; i min i <= max i max i++ i++ i {
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    } {
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    } int eachCase = 0; eachCase 0 for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      } {
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      } eachCase += (i - coordinates[j]) * (i - coordinates[j]) eachCase (i - coordinates[j]) * (i - coordinates[j]) (i - coordinates[j]) i coordinates[j] coordinates j (i - coordinates[j]) i coordinates[j] coordinates j energy = Math.min(energy,eachCase) energy Math.min(energy,eachCase) Math.min Math energy eachCase System.out.println(energy) System.out.println System.out System System.out energy String[] args args
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] coordinates = new int[n];
    int max = 1;
    int min = 100;
    for(int i = 0; i < n; i++){
      coordinates[i] = sc.nextInt();
      max = Math.max(max, coordinates[i]);
      min = Math.min(min, coordinates[i]);
    }
    int energy = 250000;
    for(int i = min; i <= max; i++){
      int eachCase = 0;
      for(int j = 0; j < n; j++){
        eachCase += (i - coordinates[j]) * (i - coordinates[j]);
      }
      energy = Math.min(energy,eachCase);
    }
    System.out.println(energy);
  }
}