INF = 1 << 60

n = gets.to_i
hs = gets.split.map(&:to_i)

# minimize
dp = Array.new(n + 2, INF)
# init
dp[0] = 0
# change min
n.times do |i|
  [1, 2].each do |d|
    k = i + d
    dp[k] = [dp[k], dp[i] + (hs[i] - (hs[k] || INF)).abs].min
  end
end

p dp[n - 1]
