# frozen_string_literal: true

def chmin(a, b)
  a > b ? b : a
end

n = gets.to_i
h = gets.split.map(&:to_i)
dp = Array.new(100_010, 10_000_000)
dp[0] = 0
(1..n - 1).each do |i|
  dp[i] = chmin(dp[i - 2] + (h[i] - h[i - 2]).abs, dp[i]) if i != 1
  dp[i] = chmin(dp[i - 1] + (h[i - 1] - h[i]).abs, dp[i])
end
puts dp[n - 1]
