Module Module1

    Sub Main()
        Dim len As Integer = 0
        Dim hogehoge() As String

        len = CType(Console.ReadLine, Integer)
        hogehoge = Console.ReadLine.Split(" "c)
        Dim bashozahyo(hogehoge.Length - 1) As Integer

        Dim count As Integer = 0
        For Each tempstr As Integer In hogehoge
            bashozahyo(count) = tempstr
            count += 1
        Next

        Dim sum As Integer = 0
        For Each a As Integer In bashozahyo
            sum += a
        Next

        'Dim basho As Integer = CInt(bashozahyo.Average)
        Dim basho As Integer = CInt(sum / bashozahyo.Length)

        Dim ans As Integer = 0

        Dim shukaicount = 0
        For Each bashogoto In bashozahyo
            ans += CInt((basho - bashogoto) * (basho - bashogoto))
            shukaicount += 1
        Next



        Console.WriteLine(ans.ToString)


    End Sub


End Module
