Module Module1
    Dim N As Integer
    Dim h(10 ^ 5 + 10) As Integer
    Dim dp(10 ^ 5 + 10) As Integer
    Const INF As Integer = 10 ^ 4 + 1

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

        For i As Integer = 0 To 10 ^ 5 + 10 - 1
            dp(i) = INF
        Next

        Console.WriteLine(Rec(N - 1))
        'Debug.WriteLine(Rec(N - 1))
    End Sub

    Function Rec(i As Integer) As Long

        If dp(i) < INF Then
            Return dp(i)
        End If

        If i = 0 Then
            Return 0
        End If

        Dim res As Long = INF

        Chmin(res, Rec(i - 1) + Math.Abs(h(i) - h(i - 1)))
        If i > 1 Then
            Chmin(res, Rec(i - 2) + Math.Abs(h(i) - h(i - 2)))
        End If

        dp(i) = res
        Return res
    End Function

    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
