#!/usr/bin/env ruby

if $0 == __FILE__
  N = gets.to_i
  H = gets.split(' ').map &:to_i

  dp = Array.new(N, 100000)
  dp[0] = 0
  dp[1] = (H[1] - H[0]).abs

  (2..(N-1)).each do |i|
    cost1 = dp[i-2] + (H[i] - H[i-2]).abs
    cost2 = dp[i-1] + (H[i] - H[i-1]).abs
    dp[i] = cost1 < cost2 ? cost1 : cost2
  end

  puts dp[N-1]
end
