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);
    }
} import java.util.*; util.* java 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);
    }
} 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);
    } main {
        
        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);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line1 = sc.nextLine(); line1 sc.nextLine() sc.nextLine sc String line2 = sc.nextLine(); line2 sc.nextLine() sc.nextLine sc int n = Integer.parseInt(line1); n Integer.parseInt(line1) Integer.parseInt Integer line1 String[] array = line2.split(" "); array line2.split(" ") line2.split line2 " " int maxPosition = 0; maxPosition 0 int minPosition = 101; 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 i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int bufPosition = Integer.parseInt(array[i]);
            if(bufPosition > maxPosition)
            {
                maxPosition = bufPosition;
            }
            if(bufPosition < minPosition)
            {
                minPosition = bufPosition;
            }
        } {
            int bufPosition = Integer.parseInt(array[i]);
            if(bufPosition > maxPosition)
            {
                maxPosition = bufPosition;
            }
            if(bufPosition < minPosition)
            {
                minPosition = bufPosition;
            }
        } int bufPosition = Integer.parseInt(array[i]); bufPosition Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i if(bufPosition > maxPosition)
            {
                maxPosition = bufPosition;
            } bufPosition > maxPosition bufPosition maxPosition {
                maxPosition = bufPosition;
            } maxPosition = bufPosition maxPosition bufPosition if(bufPosition < minPosition)
            {
                minPosition = bufPosition;
            } bufPosition < minPosition bufPosition minPosition {
                minPosition = bufPosition;
            } minPosition = bufPosition minPosition bufPosition int minSum = 1000000; 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;
            }
        } int p = minPosition; int p = minPosition; p minPosition p <= maxPosition p maxPosition p++ p++ 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;
            }
        } {
            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;
            }
        } int bufSum = 0; bufSum 0 for(int i = 0; i < n; i++)
            {
                int bufPosition = Integer.parseInt(array[i]);
                bufSum += (bufPosition - p) * (bufPosition - p);
            } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
                int bufPosition = Integer.parseInt(array[i]);
                bufSum += (bufPosition - p) * (bufPosition - p);
            } {
                int bufPosition = Integer.parseInt(array[i]);
                bufSum += (bufPosition - p) * (bufPosition - p);
            } int bufPosition = Integer.parseInt(array[i]); bufPosition Integer.parseInt(array[i]) Integer.parseInt Integer array[i] array i bufSum += (bufPosition - p) * (bufPosition - p) bufSum (bufPosition - p) * (bufPosition - p) (bufPosition - p) bufPosition p (bufPosition - p) bufPosition p if(bufSum < minSum)
            {
                minSum = bufSum;
            } bufSum < minSum bufSum minSum {
                minSum = bufSum;
            } minSum = bufSum minSum bufSum System.out.println(minSum) System.out.println System.out System System.out minSum String[] args args 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);
    }
} 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);
    }
} Main
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);
    }
}
