N = gets.to_i
h = gets.split.map(&:to_i)
h.unshift(0)

dp = Array.new(N+1, Float::INFINITY)

dp[0] = dp[1] = 0
dp[2] = (h[2] - h[1]).abs

for i in 3..N do
  dp[i] = [
    dp[i-1] + (h[i] - h[i-1]).abs,
    dp[i-2] + (h[i] - h[i-2]).abs
  ].min
end

puts dp[N]
