def min(a, b)
  a < b ? a : b
end

gets
h = gets.split(" ").map(&:to_i)


# dp[i] 足場 i に到達するまでの最小のコスト
dp = []
dp[0] = 0
dp[1] = (h[0] - h[1]).abs

2.upto(h.size - 1) {|i|
  cost1 = dp[i - 1] + (h[i] - h[i - 1]).abs
  cost2 = dp[i - 2] + (h[i] - h[i - 2]).abs
  dp[i] = min(cost1, cost2)
}

puts dp.last
