n = gets.to_i
h = gets.chomp.split(' ').map(&:to_i)
dp = Array.new(100100, 10**9)

dp[0] = 0
0.upto(n-2) do |i|
  dp[i+1] = [dp[i+1], dp[i] + (h[i] - h[i+1]).abs].min
  dp[i+2] = [dp[i+2], dp[i] + (h[i] - h[i+2]).abs].min if i+2 < n
end

print(dp[n-1])