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 a As Integer = 0 To hogehoge.Length - 1
            bashozahyo(count) = CType(hogehoge(a), Integer)
            count += 1
        Next

        Dim sum As Integer = 0
        For a As Integer = 0 To bashozahyo.Length - 1
            sum += bashozahyo(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
        For i As Integer = 0 To bashozahyo.Length - 1
            ans += CInt((basho - bashozahyo(i)) * (basho - bashozahyo(i)))
            shukaicount += 1
        Next



        Console.WriteLine(ans.ToString)

        Console.ReadKey()


    End Sub


End Module
