Module Module1
    Dim N As Integer
    Dim h(10 ^ 5 + 10) As Integer
    Dim dp(10 ^ 5 + 10) As Integer

    Sub Main()
        N = Int(Console.ReadLine)
        h = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)

        For i As Integer = 0 To N
            dp(i) = 10 ^ 6
        Next

        dp(0) = 0

        For i As Integer = 1 To N - 1
            Chmin(dp(i), dp(i - 1) + Math.Abs(h(i) - h(i - 1)))
            If i > 1 Then
                Chmin(dp(i), dp(i - 2) + Math.Abs(h(i) - h(i - 2)))
            End If
        Next
        Console.WriteLine(dp(N - 1))
        Debug.WriteLine(dp(N - 1))

    End Sub

    Function Chmin(ByRef a As Integer, b As Integer) As Boolean
        If a > b Then
            a = b
            Return True
        End If
        Return False
    End Function
End Module
