n = gets.chomp.to_i
h_arr = [0] + gets.chomp.split(" ").map(&:to_i)

# i番目にたどり着くまでのコストの総和の最小値
dp = [0, 0]

(0..n-2).each do |i|
  dp[i + 2] = [
    dp[i] + (h_arr[i+2] - h_arr[i]).abs,
    dp[i+1] + (h_arr[i+2] - h_arr[i+1]).abs,
  ].min
end
puts dp[n]