Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim arrayH As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)
    Dim dp(0 To n - 1) As Long
    dp(0) = 0
    For j As Long = 1 To n - 1
      If j = 1 Then 
        dp(j) = Math.Abs(arrayH(j - 1) - arrayH(j))
      Else
        Dim jump1 As Long = Math.Abs(arrayH(j - 1) - arrayH(j)) + dp(j - 1)
        Dim jump2 As Long = Math.Abs(arrayH(j - 2) - arrayH(j)) + dp(j - 2)
        dp(j) = If(jump1 < jump2, jump1, jump2)
      End If
    Next
    Console.WriteLine(dp(n - 1).ToString())
  End Sub
End Class