n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
INF = 10 ** 9

dp = Array.new(10 ** 5 + 5, INF)

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

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