import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int sc1 = Integer.parseInt(scanner.nextLine());
        String array[] = (scanner.nextLine().split(" ")); 
        double sum = 0;
        for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        }
        double ave = Math.round(sum/sc1);
        double sum2 = 0;
        for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        }
        System.out.println((int)sum2);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int sc1 = Integer.parseInt(scanner.nextLine());
        String array[] = (scanner.nextLine().split(" ")); 
        double sum = 0;
        for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        }
        double ave = Math.round(sum/sc1);
        double sum2 = 0;
        for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        }
        System.out.println((int)sum2);
    }
} Main public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int sc1 = Integer.parseInt(scanner.nextLine());
        String array[] = (scanner.nextLine().split(" ")); 
        double sum = 0;
        for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        }
        double ave = Math.round(sum/sc1);
        double sum2 = 0;
        for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        }
        System.out.println((int)sum2);
    } main {
        Scanner scanner = new Scanner(System.in);
        int sc1 = Integer.parseInt(scanner.nextLine());
        String array[] = (scanner.nextLine().split(" ")); 
        double sum = 0;
        for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        }
        double ave = Math.round(sum/sc1);
        double sum2 = 0;
        for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        }
        System.out.println((int)sum2);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int sc1 = Integer.parseInt(scanner.nextLine()); sc1 Integer.parseInt(scanner.nextLine()) Integer.parseInt Integer scanner.nextLine() scanner.nextLine scanner String array[] = (scanner.nextLine().split(" ")); array (scanner.nextLine().split(" ")) scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " double sum = 0; sum 0 for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        } int i=0; int i=0; i 0 i<sc1 i sc1 i++ i++ i {
                sum += Integer.parseInt(array[i]);
        } {
                sum += Integer.parseInt(array[i]);
        } sum += Integer.parseInt(array[i]) sum Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i double ave = Math.round(sum/sc1); ave Math.round(sum/sc1) Math.round Math sum/sc1 sum sc1 double sum2 = 0; sum2 0 for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        } int i=0; int i=0; i 0 i<sc1 i sc1 i++ i++ i {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        } {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        } sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2) sum2 Math.pow(Integer.parseInt(array[i]) - ave,2) Math.pow Math Integer.parseInt(array[i]) - ave Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i ave 2 System.out.println((int)sum2) System.out.println System.out System System.out (int)sum2 String[] args args
import java.util.Scanner;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int sc1 = Integer.parseInt(scanner.nextLine());
        String array[] = (scanner.nextLine().split(" ")); 
        double sum = 0;
        for( int i=0; i<sc1; i++ ) {
                sum += Integer.parseInt(array[i]);
        }
        double ave = Math.round(sum/sc1);
        double sum2 = 0;
        for( int i=0; i<sc1; i++ ) {
                sum2 += Math.pow(Integer.parseInt(array[i]) - ave,2);
        }
        System.out.println((int)sum2);
    }
}