import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        
        int n = Integer.parseInt(line1);
        String[] array = line2.split(" ");
        
        int maxPosition = 0;
        int minPosition = 101;
        
        for(int i = 0; i < n; i++)
        {
            int bufPosition = Integer.parseInt(array[i]);
            if(bufPosition > maxPosition)
            {
                maxPosition = bufPosition;
            }
            if(bufPosition < minPosition)
            {
                minPosition = bufPosition;
            }
        }
        int minSum = 1000000;
        for(int p = minPosition; p <= maxPosition; p++)
        {
            int bufSum = 0;
            for(int i = 0; i < n; i++)
            {
                int bufPosition = Integer.parseInt(array[i]);
                bufSum += (bufPosition - p) * (bufPosition - p);
            }
            if(bufSum < minSum)
            {
                minSum = bufSum;
            }
        }    
        System.out.println(minSum);
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz