N, *H = [gets, *gets.split].map(&:to_i)

dp = [0, (H[0]-H[1]).abs]
2.step(N-1) do |i|
  jmp1 = dp[i-1] + (H[i-1] - H[i]).abs
  jmp2 = dp[i-2]+(H[i-2] - H[i]).abs
  dp[i] = jmp1 < jmp2 ? jmp1 : jmp2
end
puts dp.last
